diff --git a/assertj-refaster-rules/build.gradle b/assertj-refaster-rules/build.gradle deleted file mode 100644 index 4e4a854e..00000000 --- a/assertj-refaster-rules/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -apply plugin: 'java-library' -apply plugin: 'com.palantir.external-publish-jar' - -dependencies { - implementation 'com.google.errorprone:error_prone_refaster' - implementation 'org.assertj:assertj-core' - - testImplementation 'junit:junit' - testImplementation 'com.palantir.baseline:baseline-refaster-testing' - testImplementation 'org.junit.jupiter:junit-jupiter' - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine', { - because 'allows JUnit 3 and JUnit 4 tests to run' - } -} - -// we don't want to auto-fix all the @BeforeTemplates! -tasks.compileRefaster.enabled = false -tasks.compileJava.options.errorprone.enabled = false -tasks.checkClassUniqueness.enabled = false - diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjArrayEquals.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjArrayEquals.java deleted file mode 100644 index 158bdebf..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjArrayEquals.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Arrays; - -public final class AssertjArrayEquals { - - @BeforeTemplate - void bytes(byte[] actual, byte[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void shorts(short[] actual, short[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void ints(int[] actual, int[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void longs(long[] actual, long[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void floats(float[] actual, float[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void doubles(double[] actual, double[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void chars(char[] actual, char[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void booleans(boolean[] actual, boolean[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void arbitraryObjects(T[] actual, T[] expected) { - assertThat(Arrays.equals(actual, expected)).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T[] actual, T[] expected) { - assertThat(actual).isEqualTo(expected); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsFalse.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsFalse.java deleted file mode 100644 index 04d89e70..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsFalse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjBooleanNegationIsFalse { - - @BeforeTemplate - void before(boolean input) { - assertThat(!input).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(boolean input) { - assertThat(input).isTrue(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsFalseWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsFalseWithDescription.java deleted file mode 100644 index fce8b71c..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsFalseWithDescription.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjBooleanNegationIsFalseWithDescription { - - @BeforeTemplate - void before(boolean input, String description, @Repeated Object descriptionArgs) { - assertThat(!input).describedAs(description, descriptionArgs).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(boolean input, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).isTrue(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsTrue.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsTrue.java deleted file mode 100644 index 20396c06..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsTrue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjBooleanNegationIsTrue { - - @BeforeTemplate - void before(boolean input) { - assertThat(!input).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(boolean input) { - assertThat(input).isFalse(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsTrueWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsTrueWithDescription.java deleted file mode 100644 index 2612425d..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjBooleanNegationIsTrueWithDescription.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjBooleanNegationIsTrueWithDescription { - - @BeforeTemplate - void before(boolean input, String description, @Repeated Object descriptionArgs) { - assertThat(!input).describedAs(description, descriptionArgs).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(boolean input, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).isFalse(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmpty.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmpty.java deleted file mode 100644 index c2e51406..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmpty.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Collection; - -public final class AssertjCollectionIsEmpty { - - @BeforeTemplate - void bad1(Collection things) { - assertThat(things.size() == 0).isTrue(); - } - - @BeforeTemplate - void bad2(Collection things) { - assertThat(things.isEmpty()).isTrue(); - } - - @BeforeTemplate - void bad3(Collection things) { - assertThat(things.size()).isZero(); - } - - @BeforeTemplate - void bad4(Collection things) { - assertThat(things.size()).isEqualTo(0); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Iterable things) { - assertThat(things).isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmpty2.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmpty2.java deleted file mode 100644 index b8be6b70..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmpty2.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.errorprone.refaster.Refaster; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import java.util.Collections; -import org.assertj.core.api.AbstractAssert; -import org.assertj.core.api.AbstractIterableAssert; - -public final class AssertjCollectionIsEmpty2< - A extends AbstractIterableAssert, - I extends Iterable, - T, - E extends AbstractAssert> { - - @BeforeTemplate - void before1(A in) { - in.hasSize(0); - } - - @BeforeTemplate - void before2(A in) { - in.isEqualTo( - Refaster.anyOf(ImmutableList.of(), ImmutableSet.of(), Collections.emptySet(), Collections.emptyList())); - } - - @AfterTemplate - void after(A in) { - in.isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmptyWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmptyWithDescription.java deleted file mode 100644 index e9f22105..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsEmptyWithDescription.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Collection; - -public final class AssertjCollectionIsEmptyWithDescription { - - @BeforeTemplate - void bad1(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size() == 0).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void bad2(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.isEmpty()).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void bad3(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size()).describedAs(description, descriptionArgs).isZero(); - } - - @BeforeTemplate - void bad4(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size()).describedAs(description, descriptionArgs).isEqualTo(0); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Iterable things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmpty.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmpty.java deleted file mode 100644 index 84ea0977..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmpty.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Collection; -import java.util.Collections; - -public final class AssertjCollectionIsNotEmpty { - - @BeforeTemplate - void bad1(Collection things) { - assertThat(things.size() != 0).isTrue(); - } - - @BeforeTemplate - void bad2(Collection things) { - assertThat(things.size() == 0).isFalse(); - } - - @BeforeTemplate - void bad3(Collection things) { - assertThat(things.size()).isNotEqualTo(0); - } - - @BeforeTemplate - void bad4(Collection things) { - assertThat(things.isEmpty()).isFalse(); - } - - @BeforeTemplate - void bad5(Collection things) { - assertThat(!things.isEmpty()).isTrue(); - } - - @BeforeTemplate - void bad6(Collection things) { - assertThat(things).isNotEqualTo(Collections.emptyList()); - } - - @BeforeTemplate - void bad7(Collection things) { - assertThat(things).isNotEqualTo(Collections.emptySet()); - } - - @BeforeTemplate - void bad8(Collection things) { - assertThat(things).isNotEqualTo(ImmutableList.of()); - } - - @BeforeTemplate - void bad9(Collection things) { - assertThat(things).isNotEqualTo(ImmutableSet.of()); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Collection things) { - assertThat(things).isNotEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmptyWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmptyWithDescription.java deleted file mode 100644 index c09c6dd4..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmptyWithDescription.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Collection; -import java.util.Collections; - -public final class AssertjCollectionIsNotEmptyWithDescription { - - @BeforeTemplate - void bad1(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size() != 0).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void bad2(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size() == 0).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void bad3(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size()).describedAs(description, descriptionArgs).isNotEqualTo(0); - } - - @BeforeTemplate - void bad4(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things.isEmpty()).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void bad5(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(!things.isEmpty()).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void bad6(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(Collections.emptyList()); - } - - @BeforeTemplate - void bad7(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(Collections.emptySet()); - } - - @BeforeTemplate - void bad8(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(ImmutableList.of()); - } - - @BeforeTemplate - void bad9(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isNotEqualTo(ImmutableSet.of()); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Collection things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isNotEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjDescribedAsFormat.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjDescribedAsFormat.java deleted file mode 100644 index 7e1d63b4..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjDescribedAsFormat.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import org.assertj.core.api.Descriptable; - -public final class AssertjDescribedAsFormat> { - - @BeforeTemplate - public T before(T assertion, String format, @Repeated Object formatArgs) { - return assertion.describedAs(String.format(format, formatArgs)); - } - - @AfterTemplate - public T after(T assertion, String format, @Repeated Object formatArgs) { - return assertion.describedAs(format, formatArgs); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjEquals.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjEquals.java deleted file mode 100644 index 15ecf819..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjEquals.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -/** - * We have to guess as to which value is expected and which is the actual result, but either way failures will produce - * significantly more helpful output. - */ -public final class AssertjEquals { - - @BeforeTemplate - void before1(T expected, T actual) { - assertThat(actual.equals(expected)).isTrue(); - } - - @BeforeTemplate - void before2(T expected, T actual) { - assertThat(Objects.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void before3(T expected, T actual) { - assertThat(!actual.equals(expected)).isFalse(); - } - - @BeforeTemplate - void before4(T expected, T actual) { - assertThat(!Objects.equals(actual, expected)).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T expected, T actual) { - assertThat(actual).isEqualTo(expected); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjEqualsWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjEqualsWithDescription.java deleted file mode 100644 index 34cfcf05..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjEqualsWithDescription.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -/** - * We have to guess as to which value is expected and which is the actual result, but either way failures will produce - * significantly more helpful output. - */ -public final class AssertjEqualsWithDescription { - - @BeforeTemplate - void before1(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(actual.equals(expected)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before2(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(Objects.equals(actual, expected)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before3(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(!actual.equals(expected)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @BeforeTemplate - void before4(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(!Objects.equals(actual, expected)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(actual).describedAs(description, descriptionArgs).isEqualTo(expected); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjFileContent.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjFileContent.java deleted file mode 100644 index 0c6d901d..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjFileContent.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.common.io.Files; -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -public final class AssertjFileContent { - - @BeforeTemplate - void before(File file, String expected) throws IOException { - assertThat(new String(Files.toByteArray(file), StandardCharsets.UTF_8)).isEqualTo(expected); - } - - @BeforeTemplate - @SuppressWarnings("deprecation") // we're migrating people off a deprecated method - void before2(File file, String expected) throws IOException { - assertThat(Files.toString(file, StandardCharsets.UTF_8)).isEqualTo(expected); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(File file, String expected) { - assertThat(file).hasContent(expected); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjInstanceOf.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjInstanceOf.java deleted file mode 100644 index 0bb872ec..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjInstanceOf.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.Refaster; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -/** - * We have to guess as to which value is expected and which is the actual result, but either way failures will produce - * significantly more helpful output. - */ -public final class AssertjInstanceOf { - - @BeforeTemplate - void before(T input) { - assertThat(Refaster.isInstance(input)).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T input) { - assertThat(input).isInstanceOf(Refaster.clazz()); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjInstanceOfWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjInstanceOfWithDescription.java deleted file mode 100644 index 7390b4cb..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjInstanceOfWithDescription.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.Refaster; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjInstanceOfWithDescription { - - @BeforeTemplate - void before(T input, String description, @Repeated Object descriptionArgs) { - assertThat(Refaster.isInstance(input)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T input, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).isInstanceOf(Refaster.clazz()); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjIsNull.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjIsNull.java deleted file mode 100644 index 331cd498..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjIsNull.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -public final class AssertjIsNull { - - @BeforeTemplate - void before1(Object input) { - assertThat(input == null).isTrue(); - } - - @BeforeTemplate - void before2(Object input) { - assertThat(input != null).isFalse(); - } - - @BeforeTemplate - void before3(Object input) { - assertThat(Objects.isNull(input)).isTrue(); - } - - @BeforeTemplate - void before4(Object input) { - assertThat(Objects.nonNull(input)).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Object input) { - assertThat(input).isNull(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjIsNullWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjIsNullWithDescription.java deleted file mode 100644 index 76609dbb..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjIsNullWithDescription.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -public final class AssertjIsNullWithDescription { - - @BeforeTemplate - void before1(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(input == null).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before2(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(input != null).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void before3(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(Objects.isNull(input)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before4(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(Objects.nonNull(input)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).isNull(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsEntry.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsEntry.java deleted file mode 100644 index 5417264e..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsEntry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapContainsEntry { - - @BeforeTemplate - void before(Map things, K key, V expectedValue) { - assertThat(things.get(key)).isEqualTo(expectedValue); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, K key, V expectedValue) { - assertThat(things).containsEntry(key, expectedValue); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsEntryWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsEntryWithDescription.java deleted file mode 100644 index b5b2a748..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsEntryWithDescription.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapContainsEntryWithDescription { - - @BeforeTemplate - void before(Map things, K key, V expectedValue, String description, @Repeated Object descriptionArgs) { - assertThat(things.get(key)).describedAs(description, descriptionArgs).isEqualTo(expectedValue); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, K key, V expectedValue, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).containsEntry(key, expectedValue); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsKey.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsKey.java deleted file mode 100644 index 54dc7710..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsKey.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapContainsKey { - - @BeforeTemplate - void before1(Map things, K key) { - assertThat(things.containsKey(key)).isTrue(); - } - - @BeforeTemplate - @SuppressWarnings("RedundantCollectionOperation") // It's what we're fixing - void before2(Map things, K key) { - assertThat(things.keySet().contains(key)).isTrue(); - } - - @BeforeTemplate - void before3(Map things, K key) { - assertThat(things.get(key)).isNotNull(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, K key) { - assertThat(things).containsKey(key); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsKeyWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsKeyWithDescription.java deleted file mode 100644 index 41f7fb30..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapContainsKeyWithDescription.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapContainsKeyWithDescription { - - @BeforeTemplate - void before1(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things.containsKey(key)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - @SuppressWarnings("RedundantCollectionOperation") // It's what we're fixing - void before2(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things.keySet().contains(key)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before3(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things.get(key)).describedAs(description, descriptionArgs).isNotNull(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).containsKey(key); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapDoesNotContainKey.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapDoesNotContainKey.java deleted file mode 100644 index 8d4869bb..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapDoesNotContainKey.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapDoesNotContainKey { - - @BeforeTemplate - void before1(Map things, K key) { - assertThat(things.containsKey(key)).isFalse(); - } - - @BeforeTemplate - void before2(Map things, K key) { - assertThat(things.get(key)).isNull(); - } - - @BeforeTemplate - @SuppressWarnings("RedundantCollectionOperation") // It's what we're fixing - void before3(Map things, K key) { - assertThat(things.keySet().contains(key)).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, K key) { - assertThat(things).doesNotContainKey(key); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapDoesNotContainKeyWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapDoesNotContainKeyWithDescription.java deleted file mode 100644 index ec085da7..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapDoesNotContainKeyWithDescription.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapDoesNotContainKeyWithDescription { - - @BeforeTemplate - void before1(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things.containsKey(key)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @BeforeTemplate - void before2(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things.get(key)).describedAs(description, descriptionArgs).isNull(); - } - - @BeforeTemplate - @SuppressWarnings("RedundantCollectionOperation") // It's what we're fixing - void before3(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things.keySet().contains(key)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, K key, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).doesNotContainKey(key); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmpty.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmpty.java deleted file mode 100644 index f59913cf..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmpty.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapIsEmpty { - - @BeforeTemplate - void before1(Map things) { - assertThat(things.size() == 0).isTrue(); - } - - @BeforeTemplate - void before2(Map things) { - assertThat(things.isEmpty()).isTrue(); - } - - @BeforeTemplate - void before3(Map things) { - assertThat(things.size()).isZero(); - } - - @BeforeTemplate - void before4(Map things) { - assertThat(things.size()).isEqualTo(0); - } - - @BeforeTemplate - void before5(Map things) { - assertThat(things).hasSize(0); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things) { - assertThat(things).isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmpty2.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmpty2.java deleted file mode 100644 index 9c0dc158..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmpty2.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.google.common.collect.ImmutableMap; -import com.google.errorprone.refaster.Refaster; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import java.util.Collections; -import org.assertj.core.api.MapAssert; - -public final class AssertjMapIsEmpty2, K, V> { - - @BeforeTemplate - void before1(A in) { - in.hasSize(0); - } - - @BeforeTemplate - void before2(A in) { - in.isEqualTo(Refaster.anyOf(ImmutableMap.of(), Collections.emptyMap())); - } - - @AfterTemplate - void after(A in) { - in.isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmptyWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmptyWithDescription.java deleted file mode 100644 index 9dc62b43..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjMapIsEmptyWithDescription.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Map; - -public final class AssertjMapIsEmptyWithDescription { - - @BeforeTemplate - void before1(Map things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size() == 0).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before2(Map things, String description, @Repeated Object descriptionArgs) { - assertThat(things.isEmpty()).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before3(Map things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size()).describedAs(description, descriptionArgs).isZero(); - } - - @BeforeTemplate - void before4(Map things, String description, @Repeated Object descriptionArgs) { - assertThat(things.size()).describedAs(description, descriptionArgs).isEqualTo(0); - } - - @BeforeTemplate - void before5(Map things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).hasSize(0); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Map things, String description, @Repeated Object descriptionArgs) { - assertThat(things).describedAs(description, descriptionArgs).isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotEquals.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotEquals.java deleted file mode 100644 index 78fa8142..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotEquals.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -/** - * We have to guess as to which value is expected and which is the actual result, but either way failures will produce - * significantly more helpful output. - */ -public final class AssertjNotEquals { - - @BeforeTemplate - void before1(T expected, T actual) { - assertThat(!actual.equals(expected)).isTrue(); - } - - @BeforeTemplate - void before2(T expected, T actual) { - assertThat(!Objects.equals(actual, expected)).isTrue(); - } - - @BeforeTemplate - void before3(T expected, T actual) { - assertThat(actual.equals(expected)).isFalse(); - } - - @BeforeTemplate - void before4(T expected, T actual) { - assertThat(Objects.equals(actual, expected)).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T expected, T actual) { - assertThat(actual).isNotEqualTo(expected); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotEqualsWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotEqualsWithDescription.java deleted file mode 100644 index 0b5b49c9..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotEqualsWithDescription.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -/** - * We have to guess as to which value is expected and which is the actual result, but either way failures will produce - * significantly more helpful output. - */ -public final class AssertjNotEqualsWithDescription { - - @BeforeTemplate - void before1(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(!actual.equals(expected)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before2(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(!Objects.equals(actual, expected)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before3(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(actual.equals(expected)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @BeforeTemplate - void before4(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(Objects.equals(actual, expected)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(T expected, T actual, String description, @Repeated Object descriptionArgs) { - assertThat(actual).describedAs(description, descriptionArgs).isNotEqualTo(expected); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotNull.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotNull.java deleted file mode 100644 index a88095af..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotNull.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -public final class AssertjNotNull { - - @BeforeTemplate - void before1(Object input) { - assertThat(input == null).isFalse(); - } - - @BeforeTemplate - void before2(Object input) { - assertThat(input != null).isTrue(); - } - - @BeforeTemplate - void before3(Object input) { - assertThat(Objects.isNull(input)).isFalse(); - } - - @BeforeTemplate - void before4(Object input) { - assertThat(Objects.nonNull(input)).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Object input) { - assertThat(input).isNotNull(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotNullWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotNullWithDescription.java deleted file mode 100644 index add18ec1..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjNotNullWithDescription.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Objects; - -public final class AssertjNotNullWithDescription { - - @BeforeTemplate - void before1(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(input == null).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void before2(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(input != null).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before3(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(Objects.isNull(input)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @BeforeTemplate - void before4(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(Objects.nonNull(input)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Object input, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).isNotNull(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContains.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContains.java deleted file mode 100644 index f3623e5f..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContains.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalContains { - - @BeforeTemplate - void before(Optional optional, T innerValue) { - assertThat(optional.get()).isEqualTo(innerValue); - } - - @BeforeTemplate - void before2(Optional optional, T innerValue) { - assertThat(optional).isEqualTo(Optional.of(innerValue)); - } - - @BeforeTemplate - void before3(Optional optional, T innerValue) { - assertThat(optional.isPresent() && optional.get().equals(innerValue)).isTrue(); - } - - @BeforeTemplate - void redundantAssertion1(Optional optional, T innerValue) { - assertThat(optional).isPresent(); - assertThat(optional).hasValue(innerValue); - } - - @BeforeTemplate - void redundantAssertion2(Optional optional, T innerValue) { - assertThat(optional).isPresent(); - assertThat(optional).contains(innerValue); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Optional optional, T innerValue) { - assertThat(optional).contains(innerValue); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContainsRedundantWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContainsRedundantWithDescription.java deleted file mode 100644 index 33594537..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContainsRedundantWithDescription.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalContainsRedundantWithDescription { - - @BeforeTemplate - void redundantAssertion1( - Optional optional, - T innerValue, - String description1, - @Repeated Object descriptionArgs1, - String description2, - @Repeated Object descriptionArgs2) { - assertThat(optional).describedAs(description1, descriptionArgs1).isPresent(); - assertThat(optional).describedAs(description2, descriptionArgs2).hasValue(innerValue); - } - - @BeforeTemplate - void redundantAssertion2( - Optional optional, - T innerValue, - String description1, - @Repeated Object descriptionArgs1, - String description2, - @Repeated Object descriptionArgs2) { - assertThat(optional).describedAs(description1, descriptionArgs1).isPresent(); - assertThat(optional).describedAs(description2, descriptionArgs2).contains(innerValue); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after( - Optional optional, - T innerValue, - // The first assertion is unnecessary - String _description1, - @Repeated Object _descriptionArgs1, - String description2, - @Repeated Object descriptionArgs2) { - assertThat(optional).describedAs(description2, descriptionArgs2).contains(innerValue); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContainsWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContainsWithDescription.java deleted file mode 100644 index 6e823511..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalContainsWithDescription.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalContainsWithDescription { - - @BeforeTemplate - void before1(Optional optional, T innerValue, String description, @Repeated Object descriptionArgs) { - assertThat(optional.get()).describedAs(description, descriptionArgs).isEqualTo(innerValue); - } - - @BeforeTemplate - void before2(Optional optional, T innerValue, String description, @Repeated Object descriptionArgs) { - assertThat(optional).describedAs(description, descriptionArgs).isEqualTo(Optional.of(innerValue)); - } - - @BeforeTemplate - void before3(Optional optional, T innerValue, String description, @Repeated Object descriptionArgs) { - assertThat(optional.isPresent() && optional.get().equals(innerValue)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Optional optional, T innerValue, String description, @Repeated Object descriptionArgs) { - assertThat(optional).describedAs(description, descriptionArgs).contains(innerValue); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsEmpty.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsEmpty.java deleted file mode 100644 index 10d8c0c1..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsEmpty.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalIsEmpty { - - @BeforeTemplate - void before1(Optional thing) { - assertThat(thing.isPresent()).isFalse(); - } - - @BeforeTemplate - void before2(Optional thing) { - assertThat(!thing.isPresent()).isTrue(); - } - - @BeforeTemplate - void before3(Optional thing) { - assertThat(thing.isEmpty()).isTrue(); - } - - @BeforeTemplate - void before4(Optional thing) { - assertThat(!thing.isEmpty()).isFalse(); - } - - @BeforeTemplate - void before5(Optional thing) { - assertThat(thing).isEqualTo(Optional.empty()); - } - - @BeforeTemplate - void before6(Optional thing) { - assertThat(Optional.empty()).isEqualTo(thing); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Optional thing) { - assertThat(thing).isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsEmptyWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsEmptyWithDescription.java deleted file mode 100644 index 2b94fcb9..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsEmptyWithDescription.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalIsEmptyWithDescription { - - @BeforeTemplate - void before1(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing.isPresent()).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void before2(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(!thing.isPresent()).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before3(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing.isEmpty()).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before4(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(!thing.isEmpty()).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void before5(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing).describedAs(description, descriptionArgs).isEqualTo(Optional.empty()); - } - - @BeforeTemplate - void before6(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(Optional.empty()).describedAs(description, descriptionArgs).isEqualTo(thing); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing).describedAs(description, descriptionArgs).isEmpty(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsPresent.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsPresent.java deleted file mode 100644 index 2d25f5c2..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsPresent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalIsPresent { - - @BeforeTemplate - void before1(Optional thing) { - assertThat(thing.isPresent()).isTrue(); - } - - @BeforeTemplate - void before2(Optional thing) { - assertThat(!thing.isPresent()).isFalse(); - } - - @BeforeTemplate - void before3(Optional thing) { - assertThat(thing.isEmpty()).isFalse(); - } - - @BeforeTemplate - void before4(Optional thing) { - assertThat(!thing.isEmpty()).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Optional thing) { - assertThat(thing).isPresent(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsPresentWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsPresentWithDescription.java deleted file mode 100644 index ba8a1410..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjOptionalIsPresentWithDescription.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; -import java.util.Optional; - -public final class AssertjOptionalIsPresentWithDescription { - - @BeforeTemplate - void before1(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing.isPresent()).describedAs(description, descriptionArgs).isTrue(); - } - - @BeforeTemplate - void before2(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(!thing.isPresent()).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void before3(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing.isEmpty()).describedAs(description, descriptionArgs).isFalse(); - } - - @BeforeTemplate - void before4(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(!thing.isEmpty()).describedAs(description, descriptionArgs).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(Optional thing, String description, @Repeated Object descriptionArgs) { - assertThat(thing).describedAs(description, descriptionArgs).isPresent(); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringContains.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringContains.java deleted file mode 100644 index 3cf3dcce..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringContains.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjStringContains { - - @BeforeTemplate - void before1(String input, CharSequence contains) { - assertThat(input.contains(contains)).isTrue(); - } - - @BeforeTemplate - void before2(String input, CharSequence contains) { - assertThat(!input.contains(contains)).isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(String input, CharSequence contains) { - assertThat(input).contains(contains); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringContainsWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringContainsWithDescription.java deleted file mode 100644 index 8ca7e2f1..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringContainsWithDescription.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjStringContainsWithDescription { - - @BeforeTemplate - void before1(String input, CharSequence contains, String description, @Repeated Object descriptionArgs) { - assertThat(input.contains(contains)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @BeforeTemplate - void before2(String input, CharSequence contains, String description, @Repeated Object descriptionArgs) { - assertThat(!input.contains(contains)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(String input, CharSequence contains, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).contains(contains); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringDoesNotContain.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringDoesNotContain.java deleted file mode 100644 index fb57cbfc..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringDoesNotContain.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjStringDoesNotContain { - - @BeforeTemplate - void before1(String input, CharSequence contains) { - assertThat(input.contains(contains)).isFalse(); - } - - @BeforeTemplate - void before2(String input, CharSequence contains) { - assertThat(!input.contains(contains)).isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(String input, CharSequence contains) { - assertThat(input).doesNotContain(contains); - } -} diff --git a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringDoesNotContainWithDescription.java b/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringDoesNotContainWithDescription.java deleted file mode 100644 index 0887651b..00000000 --- a/assertj-refaster-rules/src/main/java/com/palantir/assertj/refaster/AssertjStringDoesNotContainWithDescription.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.errorprone.refaster.ImportPolicy; -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import com.google.errorprone.refaster.annotation.Repeated; -import com.google.errorprone.refaster.annotation.UseImportPolicy; - -public final class AssertjStringDoesNotContainWithDescription { - - @BeforeTemplate - void before1(String input, CharSequence contains, String description, @Repeated Object descriptionArgs) { - assertThat(input.contains(contains)) - .describedAs(description, descriptionArgs) - .isFalse(); - } - - @BeforeTemplate - void before2(String input, CharSequence contains, String description, @Repeated Object descriptionArgs) { - assertThat(!input.contains(contains)) - .describedAs(description, descriptionArgs) - .isTrue(); - } - - @AfterTemplate - @UseImportPolicy(ImportPolicy.STATIC_IMPORT_ALWAYS) - void after(String input, CharSequence contains, String description, @Repeated Object descriptionArgs) { - assertThat(input).describedAs(description, descriptionArgs).doesNotContain(contains); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjArrayEqualsTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjArrayEqualsTest.java deleted file mode 100644 index fe95ff59..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjArrayEqualsTest.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjArrayEqualsTest { - @Test - public void sanity_check() { - byte[] bytes = {1, 2, 3}; - // both of these work, but I think isEqualTo reads a bit more nicely - assertThat(bytes).isEqualTo(new byte[] {1, 2, 3}); - assertThat(bytes).containsExactly(new byte[] {1, 2, 3}); - } - - @Test - public void bytes() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(byte[] a, byte[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(byte[] a, byte[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void shorts() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(short[] a, short[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(short[] a, short[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void ints() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(int[] a, int[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(int[] a, int[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void longs() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(long[] a, long[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(long[] a, long[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void floats() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(float[] a, float[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(float[] a, float[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void doubles() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(double[] a, double[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(double[] a, double[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void chars() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(char[] a, char[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(char[] a, char[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void booleans() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(boolean[] a, boolean[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(boolean[] a, boolean[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } - - @Test - public void strings() { - RefasterTestHelper.forRefactoring(AssertjArrayEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(String[] a, String[] b) { assertThat(Arrays.equals(a,b)).isTrue(); }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Arrays;", - "public class Test {", - " void f(String[] a, String[] b) { assertThat(a).isEqualTo(b); }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjBooleanNegationTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjBooleanNegationTest.java deleted file mode 100644 index 528bbf1d..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjBooleanNegationTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjBooleanNegationTest { - - @Test - public void test() { - RefasterTestHelper.forRefactoring( - AssertjBooleanNegationIsFalse.class, - AssertjBooleanNegationIsFalseWithDescription.class, - AssertjBooleanNegationIsTrue.class, - AssertjBooleanNegationIsTrueWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(Object a, Object b, boolean bool) {", - " assertThat(!bool).isTrue();", - " assertThat(!a.equals(b)).isTrue();", - " assertThat(!bool).isFalse();", - " assertThat(!a.equals(b)).isFalse();", - " assertThat(!bool).describedAs(\"desc\").isTrue();", - " assertThat(!a.equals(b)).describedAs(\"desc\").isTrue();", - " assertThat(!bool).describedAs(\"desc\").isFalse();", - " assertThat(!a.equals(b)).describedAs(\"desc\").isFalse();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(Object a, Object b, boolean bool) {", - " assertThat(bool).isFalse();", - " assertThat(a.equals(b)).isFalse();", - " assertThat(bool).isTrue();", - " assertThat(a.equals(b)).isTrue();", - " assertThat(bool).describedAs(\"desc\").isFalse();", - " assertThat(a.equals(b)).describedAs(\"desc\").isFalse();", - " assertThat(bool).describedAs(\"desc\").isTrue();", - " assertThat(a.equals(b)).describedAs(\"desc\").isTrue();", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjCollectionIsEmptyTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjCollectionIsEmptyTest.java deleted file mode 100644 index 47c1351b..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjCollectionIsEmptyTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjCollectionIsEmptyTest { - - @Test - public void simple() { - RefasterTestHelper.forRefactoring(AssertjCollectionIsEmpty.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in.size() == 0).isTrue();", - " assertThat(in.isEmpty()).isTrue();", - " assertThat(in.size()).isEqualTo(0);", - " assertThat(in.size()).isZero();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " }", - "}"); - } - - @Test - public void description() { - RefasterTestHelper.forRefactoring(AssertjCollectionIsEmptyWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in.size() == 0).describedAs(\"desc\").isTrue();", - " assertThat(in.isEmpty()).describedAs(\"desc\").isTrue();", - " assertThat(in.size()).describedAs(\"desc\").isEqualTo(0);", - " assertThat(in.size()).describedAs(\"desc\").isZero();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " }", - "}"); - } - - @Test - public void test2() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjCollectionIsEmpty2.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableList;", - "import java.util.Collections;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in).hasSize(0);", - " assertThat(in).isEqualTo(ImmutableList.of());", - " assertThat(in).isEqualTo(Collections.emptyList());", - " assertThat(in).describedAs(\"desc\").hasSize(0);", - " assertThat(in).describedAs(\"desc\").isEqualTo(ImmutableList.of());", - " assertThat(in).describedAs(\"desc\").isEqualTo(Collections.emptyList());", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableList;", - "import java.util.Collections;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmptyTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmptyTest.java deleted file mode 100644 index fe7e2dfc..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjCollectionIsNotEmptyTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjCollectionIsNotEmptyTest { - - @Test - public void simple() { - RefasterTestHelper.forRefactoring(AssertjCollectionIsNotEmpty.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in.size() != 0).isTrue();", - " assertThat(in.size() == 0).isFalse();", - " assertThat(in.isEmpty()).isFalse();", - " assertThat(!in.isEmpty()).isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in).isNotEmpty();", - " assertThat(in).isNotEmpty();", - " assertThat(in).isNotEmpty();", - " assertThat(in).isNotEmpty();", - " }", - "}"); - } - - @Test - public void description() { - RefasterTestHelper.forRefactoring(AssertjCollectionIsNotEmptyWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in.size() != 0).describedAs(\"desc\").isTrue();", - " assertThat(in.size() == 0).describedAs(\"desc\").isFalse();", - " assertThat(in.isEmpty()).describedAs(\"desc\").isFalse();", - " assertThat(!in.isEmpty()).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in) {", - " assertThat(in).describedAs(\"desc\").isNotEmpty();", - " assertThat(in).describedAs(\"desc\").isNotEmpty();", - " assertThat(in).describedAs(\"desc\").isNotEmpty();", - " assertThat(in).describedAs(\"desc\").isNotEmpty();", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjDescribedAsFormatTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjDescribedAsFormatTest.java deleted file mode 100644 index e9512740..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjDescribedAsFormatTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjDescribedAsFormatTest { - - @Test - public void test() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjDescribedAsFormat.class) - .withInputLines( - "Test", - "import static java.lang.String.format;", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc %s\", \"arg\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(String.format(\"desc %s\", \"arg\")).isEqualTo(\"foo\");", - " assertThat(obj).describedAs(format(\"desc %s\", \"arg\")).isEqualTo(\"foo\");", - " }", - "}") - .hasOutputLines( - "import static java.lang.String.format;", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc %s\", \"arg\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc %s\", \"arg\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc %s\", \"arg\").isEqualTo(\"foo\");", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjEqualityTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjEqualityTest.java deleted file mode 100644 index 79f3b09a..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjEqualityTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjEqualityTest { - - @Test - public void equals_simple() { - RefasterTestHelper.forRefactoring(AssertjEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj.equals(\"foo\")).isTrue();", - " assertThat(!obj.equals(\"foo\")).isFalse();", - " assertThat(Objects.equals(obj, \"foo\")).isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).isEqualTo(\"foo\");", - " assertThat(obj).isEqualTo(\"foo\");", - " assertThat(obj).isEqualTo(\"foo\");", - " }", - "}"); - } - - @Test - public void equals_description() { - RefasterTestHelper.forRefactoring(AssertjEqualsWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj.equals(\"foo\")).describedAs(\"desc\").isTrue();", - " assertThat(!obj.equals(\"foo\")).describedAs(\"desc\").isFalse();", - " assertThat(Objects.equals(obj, \"foo\")).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).describedAs(\"desc\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isEqualTo(\"foo\");", - " }", - "}"); - } - - @Test - public void notEquals_simple() { - RefasterTestHelper.forRefactoring(AssertjNotEquals.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj.equals(\"foo\")).isFalse();", - " assertThat(!obj.equals(\"foo\")).isTrue();", - " assertThat(Objects.equals(obj, \"foo\")).isFalse();", - " assertThat(!Objects.equals(obj, \"foo\")).isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).isNotEqualTo(\"foo\");", - " assertThat(obj).isNotEqualTo(\"foo\");", - " assertThat(obj).isNotEqualTo(\"foo\");", - " assertThat(obj).isNotEqualTo(\"foo\");", - " }", - "}"); - } - - @Test - public void notEquals_description() { - RefasterTestHelper.forRefactoring(AssertjNotEqualsWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj.equals(\"foo\")).describedAs(\"desc\").isFalse();", - " assertThat(!obj.equals(\"foo\")).describedAs(\"desc\").isTrue();", - " assertThat(Objects.equals(obj, \"foo\")).describedAs(\"desc\").isFalse();", - " assertThat(!Objects.equals(obj, \"foo\")).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).describedAs(\"desc\").isNotEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isNotEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isNotEqualTo(\"foo\");", - " assertThat(obj).describedAs(\"desc\").isNotEqualTo(\"foo\");", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjInstanceOfTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjInstanceOfTest.java deleted file mode 100644 index 59687076..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjInstanceOfTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjInstanceOfTest { - - @Test - public void simple() { - RefasterTestHelper.forRefactoring(AssertjInstanceOf.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableList;", - "import java.util.List;", - "public class Test {", - " void f(List in, Object obj) {", - " assertThat(in instanceof ImmutableList).isTrue();", - " assertThat(obj instanceof String).isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableList;", - "import java.util.List;", - "public class Test {", - " void f(List in, Object obj) {", - " assertThat(in).isInstanceOf(ImmutableList.class);", - " assertThat(obj).isInstanceOf(String.class);", - " }", - "}"); - } - - @Test - public void description() { - RefasterTestHelper.forRefactoring(AssertjInstanceOfWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableList;", - "import java.util.List;", - "public class Test {", - " void f(List in, Object obj) {", - " assertThat(in instanceof ImmutableList).describedAs(\"desc\").isTrue();", - " assertThat(obj instanceof String).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableList;", - "import java.util.List;", - "public class Test {", - " void f(List in, Object obj) {", - " assertThat(in).describedAs(\"desc\").isInstanceOf(ImmutableList.class);", - " assertThat(obj).describedAs(\"desc\").isInstanceOf(String.class);", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapContainsEntryTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapContainsEntryTest.java deleted file mode 100644 index 52e30066..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapContainsEntryTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjMapContainsEntryTest { - - @Test - public void simple() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapContainsEntry.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in, String key, Object expected) {", - " assertThat(in.get(key)).isEqualTo(expected);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in, String key, Object expected) {", - " assertThat(in).containsEntry(key, expected);", - " }", - "}"); - } - - @Test - public void description() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapContainsEntryWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in, String key, Object expected) {", - " assertThat(in.get(key)).describedAs(\"desc\").isEqualTo(expected);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in, String key, Object expected) {", - " assertThat(in).describedAs(\"desc\").containsEntry(key, expected);", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapContainsKeyTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapContainsKeyTest.java deleted file mode 100644 index 45095427..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapContainsKeyTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjMapContainsKeyTest { - - @Test - public void contains_simple() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapContainsKey.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in.keySet().contains(\"foo\")).isTrue();", - " assertThat(in.containsKey(\"foo\")).isTrue();", - " assertThat(in.get(\"foo\")).isNotNull();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).containsKey(\"foo\");", - " assertThat(in).containsKey(\"foo\");", - " assertThat(in).containsKey(\"foo\");", - " }", - "}"); - } - - @Test - public void contains_description() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapContainsKeyWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in.keySet().contains(\"foo\")).describedAs(\"desc\").isTrue();", - " assertThat(in.containsKey(\"foo\")).describedAs(\"desc\").isTrue();", - " assertThat(in.get(\"foo\")).describedAs(\"desc\").isNotNull();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).describedAs(\"desc\").containsKey(\"foo\");", - " assertThat(in).describedAs(\"desc\").containsKey(\"foo\");", - " assertThat(in).describedAs(\"desc\").containsKey(\"foo\");", - " }", - "}"); - } - - @Test - public void notContain_simple() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapDoesNotContainKey.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in.keySet().contains(\"foo\")).isFalse();", - " assertThat(in.containsKey(\"foo\")).isFalse();", - " assertThat(in.get(\"foo\")).isNull();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).doesNotContainKey(\"foo\");", - " assertThat(in).doesNotContainKey(\"foo\");", - " assertThat(in).doesNotContainKey(\"foo\");", - " }", - "}"); - } - - @Test - public void notContain_description() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapDoesNotContainKeyWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in.keySet().contains(\"foo\")).describedAs(\"desc\").isFalse();", - " assertThat(in.containsKey(\"foo\")).describedAs(\"desc\").isFalse();", - " assertThat(in.get(\"foo\")).describedAs(\"desc\").isNull();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).describedAs(\"desc\").doesNotContainKey(\"foo\");", - " assertThat(in).describedAs(\"desc\").doesNotContainKey(\"foo\");", - " assertThat(in).describedAs(\"desc\").doesNotContainKey(\"foo\");", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapIsEmptyTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapIsEmptyTest.java deleted file mode 100644 index b9f61d13..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjMapIsEmptyTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjMapIsEmptyTest { - - @Test - public void simple() { - RefasterTestHelper.forRefactoring(AssertjMapIsEmpty.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in.size() == 0).isTrue();", - " assertThat(in.isEmpty()).isTrue();", - " assertThat(in.size()).isEqualTo(0);", - " assertThat(in.size()).isZero();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " }", - "}"); - } - - @Test - public void description() { - RefasterTestHelper.forRefactoring(AssertjMapIsEmptyWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in.size() == 0).describedAs(\"desc\").isTrue();", - " assertThat(in.isEmpty()).describedAs(\"desc\").isTrue();", - " assertThat(in.size()).describedAs(\"desc\").isEqualTo(0);", - " assertThat(in.size()).describedAs(\"desc\").isZero();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " }", - "}"); - } - - @Test - public void test2() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjMapIsEmpty2.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableMap;", - "import java.util.Collections;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).hasSize(0);", - " assertThat(in).isEqualTo(ImmutableMap.of());", - " assertThat(in).isEqualTo(Collections.emptyMap());", - " assertThat(in).describedAs(\"desc\").hasSize(0);", - " assertThat(in).describedAs(\"desc\").isEqualTo(ImmutableMap.of());", - " assertThat(in).describedAs(\"desc\").isEqualTo(Collections.emptyMap());", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import com.google.common.collect.ImmutableMap;", - "import java.util.Collections;", - "import java.util.Map;", - "public class Test {", - " void f(Map in) {", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjNullTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjNullTest.java deleted file mode 100644 index b87407c9..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjNullTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjNullTest { - - @Test - public void test() { - RefasterTestHelper.forRefactoring( - AssertjIsNull.class, - AssertjIsNullWithDescription.class, - AssertjNotNull.class, - AssertjNotNullWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj == null).isTrue();", - " assertThat(obj != null).isFalse();", - " assertThat(Objects.isNull(obj)).isTrue();", - " assertThat(Objects.nonNull(obj)).isFalse();", - " assertThat(obj == null).isFalse();", - " assertThat(obj != null).isTrue();", - " assertThat(Objects.isNull(obj)).isFalse();", - " assertThat(Objects.nonNull(obj)).isTrue();", - " assertThat(obj == null).describedAs(\"desc\").isTrue();", - " assertThat(obj != null).describedAs(\"desc\").isFalse();", - " assertThat(Objects.isNull(obj)).describedAs(\"desc\").isTrue();", - " assertThat(Objects.nonNull(obj)).describedAs(\"desc\").isFalse();", - " assertThat(obj == null).describedAs(\"desc\").isFalse();", - " assertThat(obj != null).describedAs(\"desc\").isTrue();", - " assertThat(Objects.isNull(obj)).describedAs(\"desc\").isFalse();", - " assertThat(Objects.nonNull(obj)).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Objects;", - "public class Test {", - " void f(Object obj) {", - " assertThat(obj).isNull();", - " assertThat(obj).isNull();", - " assertThat(obj).isNull();", - " assertThat(obj).isNull();", - " assertThat(obj).isNotNull();", - " assertThat(obj).isNotNull();", - " assertThat(obj).isNotNull();", - " assertThat(obj).isNotNull();", - " assertThat(obj).describedAs(\"desc\").isNull();", - " assertThat(obj).describedAs(\"desc\").isNull();", - " assertThat(obj).describedAs(\"desc\").isNull();", - " assertThat(obj).describedAs(\"desc\").isNull();", - " assertThat(obj).describedAs(\"desc\").isNotNull();", - " assertThat(obj).describedAs(\"desc\").isNotNull();", - " assertThat(obj).describedAs(\"desc\").isNotNull();", - " assertThat(obj).describedAs(\"desc\").isNotNull();", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjOptionalContainsTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjOptionalContainsTest.java deleted file mode 100644 index bf7420df..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjOptionalContainsTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public final class AssertjOptionalContainsTest { - - @Test - public void test() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjOptionalContains.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in, String out) {", - " assertThat(in.get()).isEqualTo(out);", - " assertThat(in).isEqualTo(Optional.of(out));", - " assertThat(in.isPresent() && in.get().equals(out)).isTrue();", - " }", - " void g(Optional in, String out) {", - " assertThat(in).isPresent();", - " assertThat(in).hasValue(out);", - " }", - " void h(Optional in, String out) {", - " assertThat(in).isPresent();", - " assertThat(in).contains(out);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in, String out) {", - " assertThat(in).contains(out);", - " assertThat(in).contains(out);", - " assertThat(in).contains(out);", - " }", - " void g(Optional in, String out) {", - " assertThat(in).contains(out);", - " ", - " }", - " void h(Optional in, String out) {", - " assertThat(in).contains(out);", - " ", - " }", - "}"); - } - - @Test - public void testWithDescription() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjOptionalContainsWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in, String out) {", - " assertThat(in.get()).describedAs(\"desc\").isEqualTo(out);", - " assertThat(in).describedAs(\"desc\").isEqualTo(Optional.of(out));", - " assertThat(in.isPresent() && in.get().equals(out)).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in, String out) {", - " assertThat(in).describedAs(\"desc\").contains(out);", - " assertThat(in).describedAs(\"desc\").contains(out);", - " assertThat(in).describedAs(\"desc\").contains(out);", - " }", - "}"); - } - - @Test - public void testWithDescriptionRedundant() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjOptionalContainsRedundantWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in, String out) {", - " assertThat(in).describedAs(\"a\").isPresent();", - " assertThat(in).describedAs(\"b\").hasValue(out);", - " }", - " void g(Optional in, String out) {", - " assertThat(in).describedAs(\"a\").isPresent();", - " assertThat(in).describedAs(\"b\").contains(out);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in, String out) {", - " assertThat(in).describedAs(\"b\").contains(out);", - " ", - " }", - " void g(Optional in, String out) {", - " assertThat(in).describedAs(\"b\").contains(out);", - " ", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjOptionalPresenceTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjOptionalPresenceTest.java deleted file mode 100644 index fa58d36d..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjOptionalPresenceTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjOptionalPresenceTest { - - @Test - public void isPresent_simple() { - RefasterTestHelper.forRefactoring(AssertjOptionalIsPresent.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in.isPresent()).isTrue();", - " assertThat(!in.isPresent()).isFalse();", - " assertThat(in.isEmpty()).isFalse();", - " assertThat(!in.isEmpty()).isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in).isPresent();", - " assertThat(in).isPresent();", - " assertThat(in).isPresent();", - " assertThat(in).isPresent();", - " }", - "}"); - } - - @Test - public void isPresent_description() { - RefasterTestHelper.forRefactoring(AssertjOptionalIsPresentWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in.isPresent()).describedAs(\"desc\").isTrue();", - " assertThat(!in.isPresent()).describedAs(\"desc\").isFalse();", - " assertThat(in.isEmpty()).describedAs(\"desc\").isFalse();", - " assertThat(!in.isEmpty()).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in).describedAs(\"desc\").isPresent();", - " assertThat(in).describedAs(\"desc\").isPresent();", - " assertThat(in).describedAs(\"desc\").isPresent();", - " assertThat(in).describedAs(\"desc\").isPresent();", - " }", - "}"); - } - - @Test - public void isEmpty_simple() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjOptionalIsEmpty.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in.isPresent()).isFalse();", - " assertThat(!in.isPresent()).isTrue();", - " assertThat(in.isEmpty()).isTrue();", - " assertThat(!in.isEmpty()).isFalse();", - " assertThat(in).isEqualTo(Optional.empty());", - " assertThat(Optional.empty()).isEqualTo(in);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " assertThat(in).isEmpty();", - " }", - "}"); - } - - @Test - public void isEmpty_description() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper.forRefactoring(AssertjOptionalIsEmptyWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in.isPresent()).describedAs(\"desc\").isFalse();", - " assertThat(!in.isPresent()).describedAs(\"desc\").isTrue();", - " assertThat(in.isEmpty()).describedAs(\"desc\").isTrue();", - " assertThat(!in.isEmpty()).describedAs(\"desc\").isFalse();", - " assertThat(in).describedAs(\"desc\").isEqualTo(Optional.empty());", - " assertThat(Optional.empty()).describedAs(\"desc\").isEqualTo(in);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.Optional;", - "public class Test {", - " void f(Optional in) {", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " assertThat(in).describedAs(\"desc\").isEmpty();", - " }", - "}"); - } -} diff --git a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjStringContentTest.java b/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjStringContentTest.java deleted file mode 100644 index 42cdd8d5..00000000 --- a/assertj-refaster-rules/src/test/java/com/palantir/assertj/refaster/AssertjStringContentTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.assertj.refaster; - -import com.palantir.baseline.refaster.RefasterTestHelper; -import org.junit.jupiter.api.Test; - -public class AssertjStringContentTest { - - @Test - public void contains_simple() { - RefasterTestHelper.forRefactoring(AssertjStringContains.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str.contains(\"foo\")).isTrue();", - " assertThat(!str.contains(\"foo\")).isFalse();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str).contains(\"foo\");", - " assertThat(str).contains(\"foo\");", - " }", - "}"); - } - - @Test - public void contains_description() { - RefasterTestHelper.forRefactoring(AssertjStringContainsWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str.contains(\"foo\")).describedAs(\"desc\").isTrue();", - " assertThat(!str.contains(\"foo\")).describedAs(\"desc\").isFalse();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str).describedAs(\"desc\").contains(\"foo\");", - " assertThat(str).describedAs(\"desc\").contains(\"foo\");", - " }", - "}"); - } - - @Test - public void notContain_simple() { - RefasterTestHelper.forRefactoring(AssertjStringDoesNotContain.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str.contains(\"foo\")).isFalse();", - " assertThat(!str.contains(\"foo\")).isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str).doesNotContain(\"foo\");", - " assertThat(str).doesNotContain(\"foo\");", - " }", - "}"); - } - - @Test - public void notContain_description() { - RefasterTestHelper.forRefactoring(AssertjStringDoesNotContainWithDescription.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str.contains(\"foo\")).describedAs(\"desc\").isFalse();", - " assertThat(!str.contains(\"foo\")).describedAs(\"desc\").isTrue();", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "public class Test {", - " void f(String str) {", - " assertThat(str).describedAs(\"desc\").doesNotContain(\"foo\");", - " assertThat(str).describedAs(\"desc\").doesNotContain(\"foo\");", - " }", - "}"); - } -} diff --git a/settings.gradle b/settings.gradle index 292774a0..a61aa601 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = "assertj-automation-root" include "assertj-error-prone" -include "assertj-refaster-rules" diff --git a/versions.lock b/versions.lock index c069298d..982c3da1 100644 --- a/versions.lock +++ b/versions.lock @@ -3,24 +3,23 @@ com.github.ben-manes.caffeine:caffeine:3.1.6 (2 constraints: ee17f057) com.github.kevinstern:software-and-algorithms:1.0 (1 constraints: 7e12fcf5) com.google.auto:auto-common:1.2.1 (3 constraints: 73322261) com.google.auto.service:auto-service:1.1.1 (1 constraints: 0505f435) -com.google.auto.service:auto-service-annotations:1.1.1 (3 constraints: 2b33dea0) +com.google.auto.service:auto-service-annotations:1.1.1 (2 constraints: 8a20341c) com.google.auto.value:auto-value-annotations:1.9 (3 constraints: 802d5ac8) com.google.code.findbugs:jsr305:3.0.2 (4 constraints: 414296e0) com.google.errorprone:error_prone_annotation:2.18.0 (4 constraints: 023e825c) com.google.errorprone:error_prone_annotations:2.18.0 (6 constraints: aa5d2c3c) com.google.errorprone:error_prone_check_api:2.18.0 (3 constraints: ed2ab758) -com.google.errorprone:error_prone_core:2.18.0 (2 constraints: 1018fe65) -com.google.errorprone:error_prone_refaster:2.18.0 (2 constraints: 401932c2) +com.google.errorprone:error_prone_core:2.18.0 (1 constraints: 3605323b) com.google.errorprone:error_prone_type_annotations:2.18.0 (1 constraints: 28115ac9) com.google.guava:failureaccess:1.0.1 (1 constraints: 140ae1b4) -com.google.guava:guava:32.1.2-jre (10 constraints: b7a5d444) +com.google.guava:guava:32.1.2-jre (9 constraints: 6c901858) com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918) com.google.j2objc:j2objc-annotations:2.8 (1 constraints: be09f5a0) com.google.protobuf:protobuf-java:3.19.2 (1 constraints: 2c1165c9) io.github.java-diff-utils:java-diff-utils:4.0 (1 constraints: 811205f6) javax.inject:javax.inject:1 (1 constraints: 32107c75) net.bytebuddy:byte-buddy:1.12.21 (1 constraints: 7d0bbfea) -org.assertj:assertj-core:3.24.2 (2 constraints: 76194add) +org.assertj:assertj-core:3.24.2 (1 constraints: 3d05473b) org.checkerframework:checker-qual:3.33.0 (3 constraints: 0725c187) org.checkerframework:dataflow-errorprone:3.27.0 (3 constraints: d03848f0) org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r (1 constraints: 4f148fee) @@ -28,16 +27,15 @@ org.pcollections:pcollections:3.1.4 (1 constraints: f51029b8) [Test dependencies] com.google.auto.value:auto-value:1.7.4 (1 constraints: 1f1221fb) -com.google.errorprone:error_prone_test_helpers:2.18.0 (2 constraints: 401932c2) +com.google.errorprone:error_prone_test_helpers:2.18.0 (1 constraints: 3605323b) com.google.googlejavaformat:google-java-format:1.13.0 (1 constraints: 8b149d75) com.google.jimfs:jimfs:1.2 (1 constraints: fb138b38) com.google.testing.compile:compile-testing:0.19 (1 constraints: 3214b94c) com.google.truth:truth:1.1.3 (2 constraints: 1126a31d) -com.palantir.baseline:baseline-refaster-testing:2.43.0 (1 constraints: 3b05443b) -junit:junit:4.13.2 (7 constraints: a272d6a6) -org.apiguardian:apiguardian-api:1.1.2 (7 constraints: 9d791b5f) +junit:junit:4.13.2 (4 constraints: b6462e23) +org.apiguardian:apiguardian-api:1.1.2 (6 constraints: 24695e60) org.hamcrest:hamcrest:2.2 (1 constraints: 720b95d5) -org.hamcrest:hamcrest-core:2.2 (4 constraints: 2b2b359e) +org.hamcrest:hamcrest-core:2.2 (3 constraints: 84262b80) org.hamcrest:hamcrest-library:2.2 (1 constraints: fc138e38) org.junit.jupiter:junit-jupiter:5.10.0 (1 constraints: 3805413b) org.junit.jupiter:junit-jupiter-api:5.10.0 (4 constraints: 3145aef5) @@ -45,7 +43,6 @@ org.junit.jupiter:junit-jupiter-engine:5.10.0 (1 constraints: 330efd49) org.junit.jupiter:junit-jupiter-migrationsupport:5.10.0 (1 constraints: 3805413b) org.junit.jupiter:junit-jupiter-params:5.10.0 (1 constraints: 330efd49) org.junit.platform:junit-platform-commons:1.10.0 (2 constraints: 2b211983) -org.junit.platform:junit-platform-engine:1.10.0 (2 constraints: 79211cad) -org.junit.vintage:junit-vintage-engine:5.10.0 (1 constraints: 3805413b) +org.junit.platform:junit-platform-engine:1.10.0 (1 constraints: d210e4c4) org.opentest4j:opentest4j:1.3.0 (2 constraints: cf209249) org.ow2.asm:asm:9.1 (1 constraints: 040aa7a4) diff --git a/versions.props b/versions.props index 607389e6..8b87be14 100644 --- a/versions.props +++ b/versions.props @@ -1,14 +1,8 @@ +com.fasterxml.jackson.*:* = 2.15.3 com.fasterxml.jackson.core:jackson-databind = 2.13.2.1 com.github.ben-manes.caffeine:caffeine = 3.1.6 -com.google.auto.service:auto-service = 1.1.1 -com.google.errorprone:error_prone_* = 2.11.0 +com.google.auto.service:* = 1.1.1 +com.google.errorprone:* = 2.11.0 com.google.guava:guava = 32.1.2-jre -com.palantir.baseline:baseline-refaster-testing = 2.43.0 - -# test deps -com.fasterxml.jackson.*:* = 2.15.3 -junit:junit = 4.13.2 -org.assertj:assertj-core = 3.24.2 -org.hamcrest:hamcrest-core = 2.2 -org.junit.vintage:* = 5.10.0 +org.assertj:* = 3.24.2 org.junit.jupiter:* = 5.10.0