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 android.adservices.adselection; 18 19 import android.adservices.common.AdSelectionSignals; 20 import android.adservices.common.AdTechIdentifier; 21 import android.adservices.common.CommonFixture; 22 import android.net.Uri; 23 24 import java.util.Collections; 25 import java.util.List; 26 27 public class AdSelectionFromOutcomesConfigFixture { 28 public static final AdTechIdentifier SAMPLE_SELLER = AdSelectionConfigFixture.SELLER; 29 public static final long SAMPLE_AD_SELECTION_ID_1 = 12345L; 30 public static final long SAMPLE_AD_SELECTION_ID_2 = 123456L; 31 public static final AdSelectionSignals SAMPLE_SELECTION_SIGNALS = 32 AdSelectionSignals.fromString("{bidFloor: 10}"); 33 public static final Uri SAMPLE_SELECTION_LOGIC_URI_1 = 34 CommonFixture.getUri(SAMPLE_SELLER, "/finalWinnerSelectionLogic"); 35 public static final Uri SAMPLE_SELECTION_LOGIC_URI_2 = 36 CommonFixture.getUri(SAMPLE_SELLER, "/openBiddingLogic"); 37 anAdSelectionFromOutcomesConfig()38 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig() { 39 return new AdSelectionFromOutcomesConfig.Builder() 40 .setSeller(SAMPLE_SELLER) 41 .setAdSelectionIds(Collections.singletonList(SAMPLE_AD_SELECTION_ID_1)) 42 .setSelectionSignals(SAMPLE_SELECTION_SIGNALS) 43 .setSelectionLogicUri(SAMPLE_SELECTION_LOGIC_URI_1) 44 .build(); 45 } 46 anAdSelectionFromOutcomesConfig( AdTechIdentifier seller)47 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig( 48 AdTechIdentifier seller) { 49 return new AdSelectionFromOutcomesConfig.Builder() 50 .setSeller(seller) 51 .setAdSelectionIds(Collections.singletonList(SAMPLE_AD_SELECTION_ID_1)) 52 .setSelectionSignals(SAMPLE_SELECTION_SIGNALS) 53 .setSelectionLogicUri(SAMPLE_SELECTION_LOGIC_URI_1) 54 .build(); 55 } 56 anAdSelectionFromOutcomesConfig( List<Long> adOutcomes)57 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig( 58 List<Long> adOutcomes) { 59 return new AdSelectionFromOutcomesConfig.Builder() 60 .setSeller(SAMPLE_SELLER) 61 .setAdSelectionIds(adOutcomes) 62 .setSelectionSignals(SAMPLE_SELECTION_SIGNALS) 63 .setSelectionLogicUri(SAMPLE_SELECTION_LOGIC_URI_1) 64 .build(); 65 } 66 anAdSelectionFromOutcomesConfig(Uri selectionUri)67 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig(Uri selectionUri) { 68 return new AdSelectionFromOutcomesConfig.Builder() 69 .setSeller(SAMPLE_SELLER) 70 .setAdSelectionIds(Collections.singletonList(SAMPLE_AD_SELECTION_ID_1)) 71 .setSelectionSignals(SAMPLE_SELECTION_SIGNALS) 72 .setSelectionLogicUri(selectionUri) 73 .build(); 74 } 75 anAdSelectionFromOutcomesConfig( List<Long> adOutcomes, AdSelectionSignals selectionSignals, Uri selectionUri)76 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig( 77 List<Long> adOutcomes, AdSelectionSignals selectionSignals, Uri selectionUri) { 78 return new AdSelectionFromOutcomesConfig.Builder() 79 .setSeller(AdTechIdentifier.fromString(selectionUri.getHost())) 80 .setAdSelectionIds(adOutcomes) 81 .setSelectionSignals(selectionSignals) 82 .setSelectionLogicUri(selectionUri) 83 .build(); 84 } 85 anAdSelectionFromOutcomesConfig( AdTechIdentifier seller, Uri selectionUri)86 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig( 87 AdTechIdentifier seller, Uri selectionUri) { 88 return new AdSelectionFromOutcomesConfig.Builder() 89 .setSeller(seller) 90 .setAdSelectionIds(Collections.singletonList(SAMPLE_AD_SELECTION_ID_1)) 91 .setSelectionSignals(SAMPLE_SELECTION_SIGNALS) 92 .setSelectionLogicUri(selectionUri) 93 .build(); 94 } 95 anAdSelectionFromOutcomesConfig( AdTechIdentifier seller, List<Long> adOutcomes, AdSelectionSignals selectionSignals, Uri selectionUri)96 public static AdSelectionFromOutcomesConfig anAdSelectionFromOutcomesConfig( 97 AdTechIdentifier seller, 98 List<Long> adOutcomes, 99 AdSelectionSignals selectionSignals, 100 Uri selectionUri) { 101 return new AdSelectionFromOutcomesConfig.Builder() 102 .setSeller(seller) 103 .setAdSelectionIds(adOutcomes) 104 .setSelectionSignals(selectionSignals) 105 .setSelectionLogicUri(selectionUri) 106 .build(); 107 } 108 } 109