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.car.telemetry.publisher; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.car.telemetry.TelemetryProto; 22 23 import java.util.List; 24 25 /** 26 * Test implementation of 27 * {@link com.android.car.telemetry.publisher.AbstractPublisher.PublisherListener}. 28 * This class is used for all PublisherTests. 29 */ 30 public class FakePublisherListener implements AbstractPublisher.PublisherListener { 31 // Default is null, value is set in onConfigFinished 32 public TelemetryProto.MetricsConfig mFinishedConfig; 33 34 // Default is null, values are set in onPublisherFailure 35 public List<TelemetryProto.MetricsConfig> mFailedConfigs; 36 public Throwable mPublisherFailure; 37 38 @Override onPublisherFailure(@onNull List<TelemetryProto.MetricsConfig> affectedConfigs, @Nullable Throwable error)39 public void onPublisherFailure(@NonNull List<TelemetryProto.MetricsConfig> affectedConfigs, 40 @Nullable Throwable error) { 41 mFailedConfigs = affectedConfigs; 42 mPublisherFailure = error; 43 } 44 45 @Override onConfigFinished(@onNull TelemetryProto.MetricsConfig metricsConfig)46 public void onConfigFinished(@NonNull TelemetryProto.MetricsConfig metricsConfig) { 47 mFinishedConfig = metricsConfig; 48 } 49 } 50