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.measurement; 18 19 import static com.android.adservices.service.measurement.EventReportFixture.ValidEventReportParams; 20 21 import android.net.Uri; 22 23 import com.android.adservices.common.WebUtil; 24 import com.android.adservices.service.measurement.util.UnsignedLong; 25 26 import java.util.List; 27 import java.util.UUID; 28 29 public final class EventReportFixture { EventReportFixture()30 private EventReportFixture() {} 31 getBaseEventReportBuild()32 public static EventReport.Builder getBaseEventReportBuild() { 33 return new EventReport.Builder() 34 .setId(UUID.randomUUID().toString()) 35 .setSourceEventId(ValidEventReportParams.SOURCE_EVENT_ID) 36 .setEnrollmentId(ValidEventReportParams.ENROLLMENT_ID) 37 .setAttributionDestinations(ValidEventReportParams.ATTRIBUTION_DESTINATIONS) 38 .setTriggerTime(1000L) 39 .setTriggerDedupKey(ValidEventReportParams.TRIGGER_DEDUP_KEY) 40 .setReportTime(ValidEventReportParams.REPORT_TIME) 41 .setStatus(ValidEventReportParams.STATUS) 42 .setDebugReportStatus(ValidEventReportParams.DEBUG_REPORT_STATUS) 43 .setSourceType(ValidEventReportParams.SOURCE_TYPE) 44 .setSourceDebugKey(ValidEventReportParams.SOURCE_DEBUG_KEY) 45 .setTriggerDebugKey(ValidEventReportParams.TRIGGER_DEBUG_KEY) 46 .setSourceId(UUID.randomUUID().toString()) 47 .setTriggerId(UUID.randomUUID().toString()) 48 .setRegistrationOrigin(ValidEventReportParams.REGISTRATION_ORIGIN) 49 .setTriggerSummaryBucket(ValidEventReportParams.TRIGGER_SUMMARY_BUCKET); 50 } 51 52 public static class ValidEventReportParams { 53 public static final UnsignedLong SOURCE_EVENT_ID = new UnsignedLong(21L); 54 public static final String ENROLLMENT_ID = "enrollment-id"; 55 public static final List<Uri> ATTRIBUTION_DESTINATIONS = 56 List.of(Uri.parse("https://bar.test")); 57 public static final long TRIGGER_TIME = 8640000000L; 58 public static final String SOURCE_ID = "source_id"; 59 public static final String TRIGGER_ID = "trigger_id"; 60 public static final UnsignedLong TRIGGER_DEDUP_KEY = new UnsignedLong(3L); 61 public static final long REPORT_TIME = 2000L; 62 public static final int STATUS = EventReport.Status.PENDING; 63 public static final int DEBUG_REPORT_STATUS = EventReport.DebugReportStatus.PENDING; 64 public static final Source.SourceType SOURCE_TYPE = Source.SourceType.NAVIGATION; 65 public static final UnsignedLong SOURCE_DEBUG_KEY = new UnsignedLong(237865L); 66 public static final UnsignedLong TRIGGER_DEBUG_KEY = new UnsignedLong(928762L); 67 public static final Uri REGISTRATION_ORIGIN = 68 WebUtil.validUri("https://subdomain.example.test"); 69 public static final String TRIGGER_SUMMARY_BUCKET = "2,3"; 70 } 71 } 72