1 /* 2 * Copyright (c) 2019 Google, Inc. 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.google.common.truth.refactorings; 18 19 import com.google.errorprone.BugCheckerRefactoringTestHelper; 20 import com.google.errorprone.CompilationTestHelper; 21 import org.junit.Before; 22 import org.junit.Test; 23 import org.junit.runner.RunWith; 24 import org.junit.runners.JUnit4; 25 26 /** @author cpovirk@google.com (Chris Povirk) */ 27 @RunWith(JUnit4.class) 28 public class CorrespondenceSubclassToFactoryCallTest { 29 private BugCheckerRefactoringTestHelper refactoringHelper; 30 private CompilationTestHelper compilationHelper; 31 32 @Before setUp()33 public void setUp() { 34 compilationHelper = 35 CompilationTestHelper.newInstance(CorrespondenceSubclassToFactoryCall.class, getClass()); 36 refactoringHelper = 37 BugCheckerRefactoringTestHelper.newInstance( 38 CorrespondenceSubclassToFactoryCall.class, getClass()); 39 } 40 41 @Test testPositiveCase()42 public void testPositiveCase() { 43 compilationHelper 44 .addSourceFile("CorrespondenceSubclassToFactoryCallPositiveCases.java") 45 .doTest(); 46 } 47 48 @Test testPositiveCase2()49 public void testPositiveCase2() { 50 compilationHelper 51 .addSourceFile("CorrespondenceSubclassToFactoryCallPositiveCases2.java") 52 .doTest(); 53 } 54 55 @Test testNegativeCase()56 public void testNegativeCase() { 57 compilationHelper 58 .addSourceFile("CorrespondenceSubclassToFactoryCallNegativeCases.java") 59 .doTest(); 60 } 61 62 @Test refactoring()63 public void refactoring() { 64 refactoringHelper 65 .addInput("CorrespondenceSubclassToFactoryCallPositiveCases.java") 66 .addOutput("CorrespondenceSubclassToFactoryCallPositiveCases_expected.java") 67 .doTest(); 68 } 69 70 @Test refactoring2()71 public void refactoring2() { 72 refactoringHelper 73 .addInput("CorrespondenceSubclassToFactoryCallPositiveCases2.java") 74 .addOutput("CorrespondenceSubclassToFactoryCallPositiveCases2_expected.java") 75 .doTest(); 76 } 77 } 78