1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.service.stats; 18 19 import static org.junit.Assert.assertEquals; 20 21 import android.adservices.common.AdServicesStatusUtils; 22 23 import org.junit.Test; 24 25 /** Unit tests for {@link RunAdSelectionProcessReportedStats}. */ 26 public class RunAdSelectionProcessReportedStatsTest { 27 static final boolean IS_RMKT_ADS_WON = true; 28 static final int DB_AD_SELECTION_SIZE_IN_BYTES = 100; 29 static final int PERSIST_AD_SELECTION_LATENCY_IN_MILLIS = 10; 30 static final int RUN_AD_SELECTION_LATENCY_IN_MILLIS = 10; 31 static final int PERSIST_AD_SELECTION_RESULT_CODE = AdServicesStatusUtils.STATUS_SUCCESS; 32 static final int RUN_AD_SELECTION_RESULT_CODE = AdServicesStatusUtils.STATUS_SUCCESS; 33 34 @Test testBuilderCreateSuccess()35 public void testBuilderCreateSuccess() { 36 RunAdSelectionProcessReportedStats stats = 37 RunAdSelectionProcessReportedStats.builder() 38 .setIsRemarketingAdsWon(IS_RMKT_ADS_WON) 39 .setDBAdSelectionSizeInBytes(DB_AD_SELECTION_SIZE_IN_BYTES) 40 .setPersistAdSelectionLatencyInMillis( 41 PERSIST_AD_SELECTION_LATENCY_IN_MILLIS) 42 .setPersistAdSelectionResultCode(PERSIST_AD_SELECTION_RESULT_CODE) 43 .setRunAdSelectionLatencyInMillis(RUN_AD_SELECTION_LATENCY_IN_MILLIS) 44 .setRunAdSelectionResultCode(RUN_AD_SELECTION_RESULT_CODE) 45 .build(); 46 assertEquals(IS_RMKT_ADS_WON, stats.getIsRemarketingAdsWon()); 47 assertEquals(DB_AD_SELECTION_SIZE_IN_BYTES, stats.getDBAdSelectionSizeInBytes()); 48 assertEquals( 49 PERSIST_AD_SELECTION_LATENCY_IN_MILLIS, 50 stats.getPersistAdSelectionLatencyInMillis()); 51 assertEquals(PERSIST_AD_SELECTION_RESULT_CODE, stats.getPersistAdSelectionResultCode()); 52 assertEquals(RUN_AD_SELECTION_LATENCY_IN_MILLIS, stats.getRunAdSelectionLatencyInMillis()); 53 assertEquals(RUN_AD_SELECTION_RESULT_CODE, stats.getRunAdSelectionResultCode()); 54 } 55 } 56