1 /* 2 * Copyright (C) 2021 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.annotationvisitor; 18 19 import static org.mockito.ArgumentMatchers.any; 20 import static org.mockito.Mockito.mock; 21 import static org.mockito.Mockito.never; 22 import static org.mockito.Mockito.verify; 23 import static org.mockito.Mockito.withSettings; 24 25 import com.android.javac.Javac; 26 27 import org.junit.Before; 28 import org.junit.Rule; 29 import org.junit.rules.TestName; 30 31 import java.io.IOException; 32 33 public class AnnotationHandlerTestBase { 34 35 @Rule 36 public TestName mTestName = new TestName(); 37 38 protected Javac mJavac; 39 protected AnnotationConsumer mConsumer; 40 protected Status mStatus; 41 42 @Before baseSetup()43 public void baseSetup() throws IOException { 44 System.out.println(String.format("\n============== STARTING TEST: %s ==============\n", 45 mTestName.getMethodName())); 46 mConsumer = mock(AnnotationConsumer.class); 47 mStatus = mock(Status.class, withSettings().verboseLogging()); 48 mJavac = new Javac(); 49 } 50 assertNoErrors()51 protected void assertNoErrors() { 52 verify(mStatus, never()).error(any(Throwable.class)); 53 verify(mStatus, never()).error(any(), any()); 54 } 55 } 56