diff --git a/.cloudbuild/graalvm/cloudbuild.yaml b/.cloudbuild/graalvm/cloudbuild.yaml index 2c458fdad8..1e3af76946 100644 --- a/.cloudbuild/graalvm/cloudbuild.yaml +++ b/.cloudbuild/graalvm/cloudbuild.yaml @@ -22,6 +22,7 @@ steps: args: [ "build", "-t", "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:${_SHARED_DEPENDENCIES_VERSION}", + "-t", "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:infrastructure-public-image-$SHORT_SHA", "--file", "graalvm_a.Dockerfile", "--build-arg", "JAVA_SHARED_CONFIG_VERSION=$_JAVA_SHARED_CONFIG_VERSION", "." @@ -35,6 +36,7 @@ steps: args: [ "build", "-t", "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:${_SHARED_DEPENDENCIES_VERSION}", + "-t", "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:infrastructure-public-image-$SHORT_SHA", "--file", "graalvm_b.Dockerfile", "--build-arg", "JAVA_SHARED_CONFIG_VERSION=$_JAVA_SHARED_CONFIG_VERSION", "." @@ -47,3 +49,5 @@ steps: images: - gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:${_SHARED_DEPENDENCIES_VERSION} - gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:${_SHARED_DEPENDENCIES_VERSION} + - gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:infrastructure-public-image-$SHORT_SHA + - gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:infrastructure-public-image-$SHORT_SHA \ No newline at end of file diff --git a/.cloudbuild/library_generation/library_generation.Dockerfile b/.cloudbuild/library_generation/library_generation.Dockerfile index f6ef6f1609..9de0bc1c2c 100644 --- a/.cloudbuild/library_generation/library_generation.Dockerfile +++ b/.cloudbuild/library_generation/library_generation.Dockerfile @@ -15,8 +15,11 @@ # build from the root of this repo: FROM gcr.io/cloud-devrel-public-resources/python -ARG SYNTHTOOL_COMMITTISH=63cc541da2c45fcfca2136c43e638da1fbae174d +SHELL [ "/bin/bash", "-c" ] + +ARG SYNTHTOOL_COMMITTISH=e36d2f164ca698f0264fb6f79ddc4b0fa024a940 ARG OWLBOT_CLI_COMMITTISH=ac84fa5c423a0069bbce3d2d869c9730c8fdf550 +ARG PROTOC_VERSION=25.3 ENV HOME=/home # install OS tools @@ -24,15 +27,23 @@ RUN apt-get update && apt-get install -y \ unzip openjdk-17-jdk rsync maven jq \ && apt-get clean +# copy source code +COPY library_generation /src + +# install protoc +WORKDIR /protoc +RUN source /src/utils/utilities.sh \ + && download_protoc "${PROTOC_VERSION}" "linux-x86_64" +# we indicate protoc is available in the container via env vars +ENV DOCKER_PROTOC_LOCATION=/protoc +ENV DOCKER_PROTOC_VERSION="${PROTOC_VERSION}" + # use python 3.11 (the base image has several python versions; here we define the default one) RUN rm $(which python3) RUN ln -s $(which python3.11) /usr/local/bin/python RUN ln -s $(which python3.11) /usr/local/bin/python3 RUN python -m pip install --upgrade pip -# copy source code -COPY library_generation /src - # install scripts as a python package WORKDIR /src RUN python -m pip install -r requirements.txt diff --git a/.github/release-please.yml b/.github/release-please.yml index c335a3f0aa..a2e978d935 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -3,4 +3,4 @@ bumpMinorPreMajor: true handleGHRelease: true primaryBranch: main manifest: true -extraFiles: ["WORKSPACE", ".cloudbuild/graalvm/cloudbuild.yaml", ".cloudbuild/graalvm/cloudbuild-test-a.yaml", ".cloudbuild/graalvm/cloudbuild-test-b.yaml", ".cloudbuild/library_generation/cloudbuild-library-generation-release.yaml" ] +extraFiles: ["WORKSPACE", ".cloudbuild/graalvm/cloudbuild.yaml", ".cloudbuild/graalvm/cloudbuild-test-a.yaml", ".cloudbuild/graalvm/cloudbuild-test-b.yaml", ".cloudbuild/library_generation/cloudbuild-library-generation-release.yaml", "generation_config.yaml"] diff --git a/.github/scripts/hermetic_library_generation.sh b/.github/scripts/hermetic_library_generation.sh new file mode 100755 index 0000000000..a2337a88a4 --- /dev/null +++ b/.github/scripts/hermetic_library_generation.sh @@ -0,0 +1,119 @@ +#!/bin/bash +set -e +# This script should be run at the root of the repository. +# This script is used to, when a pull request changes the generation +# configuration (generation_config.yaml by default): +# 1. Find whether the last commit in this pull request contains changes to +# the generation configuration and exit early if it doesn't have such a change +# since the generation result would be the same. +# 2. Compare generation configurations in the current branch (with which the +# pull request associated) and target branch (into which the pull request is +# merged); +# 3. Generate changed libraries using library_generation image; +# 4. Commit the changes to the pull request, if any. +# 5. Edit the PR body with generated pull request description, if applicable. + +# The following commands need to be installed before running the script: +# 1. git +# 2. gh +# 3. docker + +# The parameters of this script is: +# 1. target_branch, the branch into which the pull request is merged. +# 2. current_branch, the branch with which the pull request is associated. +# 3. image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation. +# 3. [optional] generation_config, the path to the generation configuration, +# the default value is generation_config.yaml in the repository root. +while [[ $# -gt 0 ]]; do +key="$1" +case "${key}" in + --target_branch) + target_branch="$2" + shift + ;; + --current_branch) + current_branch="$2" + shift + ;; + --image_tag) + image_tag="$2" + shift + ;; + --generation_config) + generation_config="$2" + shift + ;; + *) + echo "Invalid option: [$1]" + exit 1 + ;; +esac +shift +done + +if [ -z "${target_branch}" ]; then + echo "missing required argument --target_branch" + exit 1 +fi + +if [ -z "${current_branch}" ]; then + echo "missing required argument --current_branch" + exit 1 +fi + +if [ -z "${image_tag}" ]; then + echo "missing required argument --image_tag" + exit 1 +fi + +if [ -z "${generation_config}" ]; then + generation_config=generation_config.yaml + echo "Use default generation config: ${generation_config}" +fi + +workspace_name="/workspace" +baseline_generation_config="baseline_generation_config.yaml" +message="chore: generate libraries at $(date)" + +git checkout "${target_branch}" +git checkout "${current_branch}" +# if the last commit doesn't contain changes to generation configuration, +# do not generate again as the result will be the same. +change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)" +if [[ ! ("${change_of_last_commit}" == *"${generation_config}"*) ]]; then + echo "The last commit doesn't contain any changes to the generation_config.yaml, skipping the whole generation process." || true + exit 0 +fi +# copy generation configuration from target branch to current branch. +git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}" +config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true) + +# run hermetic code generation docker image. +docker run \ + --rm \ + -u "$(id -u):$(id -g)" \ + -v "$(pwd):${workspace_name}" \ + -v "$HOME"/.m2:/home/.m2 \ + gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \ + --baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \ + --current-generation-config-path="${workspace_name}/${generation_config}" + +# commit the change to the pull request. +rm -rdf output googleapis "${baseline_generation_config}" +git add --all -- ':!pr_description.txt' +changed_files=$(git diff --cached --name-only) +if [[ "${changed_files}" == "" ]]; then + echo "There is no generated code change with the generation config change ${config_diff}." + echo "Skip committing to the pull request." + exit 0 +fi + +echo "Configuration diff:" +echo "${config_diff}" +git commit -m "${message}" +git push +# set pr body if pr_description.txt is generated. +if [[ -f "pr_description.txt" ]]; then + pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") + gh pr edit "${pr_num}" --body "$(cat pr_description.txt)" +fi diff --git a/.github/scripts/update_googleapis_commit.sh b/.github/scripts/update_googleapis_commit.sh new file mode 100644 index 0000000000..b950be9af4 --- /dev/null +++ b/.github/scripts/update_googleapis_commit.sh @@ -0,0 +1,92 @@ +#!/bin/bash +set -e +# This script should be run at the root of the repository. +# This script is used to update googleapis commit to latest in generation +# configuration at the time of running and create a pull request. + +# The following commands need to be installed before running the script: +# 1. git +# 2. gh + +# The parameters of this script is: +# 1. base_branch, the base branch of the result pull request. +# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java +# 3. [optional] generation_config, the path to the generation configuration, +# the default value is generation_config.yaml in the repository root. +while [[ $# -gt 0 ]]; do +key="$1" +case "${key}" in + --base_branch) + base_branch="$2" + shift + ;; + --repo) + repo="$2" + shift + ;; + --generation_config) + generation_config="$2" + shift + ;; + *) + echo "Invalid option: [$1]" + exit 1 + ;; +esac +shift +done + +if [ -z "${base_branch}" ]; then + echo "missing required argument --base_branch" + exit 1 +fi + +if [ -z "${repo}" ]; then + echo "missing required argument --repo" + exit 1 +fi + +if [ -z "${generation_config}" ]; then + generation_config="generation_config.yaml" + echo "Use default generation config: ${generation_config}" +fi + +current_branch="generate-libraries-${base_branch}" +title="chore: update googleapis commit at $(date)" + +# try to find a open pull request associated with the branch +pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") +# create a branch if there's no open pull request associated with the +# branch; otherwise checkout the pull request. +if [ -z "${pr_num}" ]; then + git checkout -b "${current_branch}" +else + gh pr checkout "${pr_num}" +fi + +mkdir tmp-googleapis +# use partial clone because only commit history is needed. +git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis +pushd tmp-googleapis +git pull +latest_commit=$(git rev-parse HEAD) +popd +rm -rf tmp-googleapis +sed -i -e "s/^googleapis_commitish.*$/googleapis_commitish: ${latest_commit}/" "${generation_config}" + +git add "${generation_config}" +changed_files=$(git diff --cached --name-only) +if [[ "${changed_files}" == "" ]]; then + echo "The latest googleapis commit is not changed." + echo "Skip committing to the pull request." + exit 0 +fi +git commit -m "${title}" +if [ -z "${pr_num}" ]; then + git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git" + git fetch -q --unshallow remote_repo + git push -f remote_repo "${current_branch}" + gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}" +else + git push +fi diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml new file mode 100644 index 0000000000..c613fa90c9 --- /dev/null +++ b/.github/workflows/hermetic_library_generation.yaml @@ -0,0 +1,54 @@ +# Copyright 2024 Google LLC +# +# 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. +# GitHub action job to test core java library features on +# downstream client libraries before they are released. +name: Hermetic library generation upon generation config change through pull requests +on: + pull_request: + +jobs: + library_generation: + # skip pull requests come from a forked repository + if: github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - name: Build image + shell: bash + run: | + docker build \ + -f .cloudbuild/library_generation/library_generation.Dockerfile \ + -t gcr.io/cloud-devrel-public-resources/java-library-generation:latest \ + . + - name: Install gapic-generator-java-pom-parent + shell: bash + run: | + mvn clean install -pl gapic-generator-java-pom-parent + - name: Generate changed libraries + shell: bash + run: | + set -x + [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" + [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" + bash .github/scripts/hermetic_library_generation.sh \ + --target_branch "${base_ref}" \ + --current_branch "${head_ref}" \ + --image_tag latest + env: + base_ref: ${{ github.base_ref }} + head_ref: ${{ github.head_ref }} + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/.github/workflows/update_googleapis_commit.yaml b/.github/workflows/update_googleapis_commit.yaml new file mode 100644 index 0000000000..2e64d5588b --- /dev/null +++ b/.github/workflows/update_googleapis_commit.yaml @@ -0,0 +1,42 @@ +# Copyright 2024 Google LLC +# +# 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. +# GitHub action job to test core java library features on +# downstream client libraries before they are released. +name: Update googleapis commit +on: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +jobs: + update-googleapis-commit: + runs-on: ubuntu-22.04 + env: + # the branch into which the pull request is merged + base_branch: main + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - name: Update googleapis commit to latest + shell: bash + run: | + set -x + [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" + [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" + bash .github/scripts/update_googleapis_commit.sh \ + --base_branch "${base_branch}"\ + --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java b/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java index a51bdff91b..85e3a060bb 100644 --- a/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java +++ b/api-common-java/src/test/java/com/google/api/pathtemplate/PathTemplateTest.java @@ -36,7 +36,6 @@ import java.util.Set; import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -302,7 +301,6 @@ void complexResourceIdEqualsWildcard() { } @Test - @Disabled("https://github.com/googleapis/sdk-platform-java/issues/2778") void complexResourceIdEqualsPathWildcard() { Exception exception = Assertions.assertThrows( @@ -312,15 +310,6 @@ void complexResourceIdEqualsPathWildcard() { String.format( "parse error: wildcard path not allowed in complex ID resource '%s'", "zone_a"), exception.getMessage()); - - exception = - Assertions.assertThrows( - ValidationException.class, - () -> PathTemplate.create("projects/{project=*}/zones/{zone_a}.{zone_b=**}")); - Assertions.assertEquals( - String.format( - "parse error: wildcard path not allowed in complex ID resource '%s'", "zone_b"), - exception.getMessage()); } @Test @@ -360,9 +349,18 @@ void complexResourceIdNoSeparator() { "parse error: missing or 2+ consecutive delimiter characters in '%s'", "{zone_a}_{zone_b}{zone_c}"), exception.getMessage()); + + exception = + Assertions.assertThrows( + ValidationException.class, + () -> PathTemplate.create("projects/{project=*}/zones/{zone_a}{{zone_b}")); + Assertions.assertEquals( + String.format( + "parse error: missing or 2+ consecutive delimiter characters in '%s'", + "{zone_a}{{zone_b}"), + exception.getMessage()); } - @Disabled("https://github.com/googleapis/sdk-platform-java/issues/2776") @ParameterizedTest @MethodSource("invalidDelimiters") void complexResourceIdInvalidDelimiter(String invalidDelimiter) { @@ -381,7 +379,7 @@ void complexResourceIdInvalidDelimiter(String invalidDelimiter) { } static Stream invalidDelimiters() { - return Stream.of("|", "!", "@", "a", "1", ",", "{", ")"); + return Stream.of("|", "!", "@", "a", "1", ",", ")"); } @Test diff --git a/gapic-generator-java/pom.xml b/gapic-generator-java/pom.xml index 750887cb89..a8eff0a3bf 100644 --- a/gapic-generator-java/pom.xml +++ b/gapic-generator-java/pom.xml @@ -476,5 +476,17 @@ 4.12 test + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/JavaCodeGeneratorTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/JavaCodeGeneratorTest.java index 558952ddf1..f759fec870 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/JavaCodeGeneratorTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/JavaCodeGeneratorTest.java @@ -60,9 +60,9 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaCodeGeneratorTest { +class JavaCodeGeneratorTest { private static final String GOLDENFILES_DIRECTORY = "src/test/java/com/google/api/generator/engine/goldens/"; @@ -101,7 +101,7 @@ public class JavaCodeGeneratorTest { private static final Variable bookKindVar = createVarFromVaporRef(bookKindRef, "bookKind"); @Test - public void validJavaClass() { + void validJavaClass() { // Create outer class variableDecls. // [code] private static final String serviceName = "LibraryServiceStub"; VariableExpr serviceName = createServiceNameVarExpr(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AnonymousClassExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AnonymousClassExprTest.java index 9fab46d98d..cfdbbfe6f2 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AnonymousClassExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AnonymousClassExprTest.java @@ -20,11 +20,11 @@ import com.google.common.base.Function; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class AnonymousClassExprTest { +class AnonymousClassExprTest { @Test - public void validAnonymousClass_basic() { + void validAnonymousClass_basic() { ConcreteReference ref = ConcreteReference.withClazz(Runnable.class); TypeNode type = TypeNode.withReference(ref); AssignmentExpr assignmentExpr = createAssignmentExpr("foobar", "false", TypeNode.BOOLEAN); @@ -45,7 +45,7 @@ public void validAnonymousClass_basic() { } @Test - public void validAnonymousClass_genericAndVariableExpr() { + void validAnonymousClass_genericAndVariableExpr() { // [Constructing] new Function() ConcreteReference ref = ConcreteReference.builder() @@ -100,14 +100,14 @@ public void validAnonymousClass_genericAndVariableExpr() { } @Test - public void invalidAnonymousClass_primitiveType() { + void invalidAnonymousClass_primitiveType() { assertThrows( IllegalStateException.class, () -> AnonymousClassExpr.builder().setType(TypeNode.INT).build()); } @Test - public void invalidAnonymousClass_staticMethod() { + void invalidAnonymousClass_staticMethod() { ConcreteReference ref = ConcreteReference.withClazz(Runnable.class); TypeNode type = TypeNode.withReference(ref); MethodDefinition method = @@ -127,7 +127,7 @@ public void invalidAnonymousClass_staticMethod() { } @Test - public void invalidAnonymousClass_explicitConstructor() { + void invalidAnonymousClass_explicitConstructor() { TypeNode type = TypeNode.withReference(ConcreteReference.withClazz(Runnable.class)); TypeNode returnType = TypeNode.withReference( @@ -143,7 +143,7 @@ public void invalidAnonymousClass_explicitConstructor() { } @Test - public void invalidAnonymousClass_staticVariableExpr() { + void invalidAnonymousClass_staticVariableExpr() { ConcreteReference ref = ConcreteReference.withClazz(Runnable.class); TypeNode type = TypeNode.withReference(ref); Variable variable = createVariable("s", TypeNode.STRING); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArithmeticOperationExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArithmeticOperationExprTest.java index 4505064472..d19a117974 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArithmeticOperationExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArithmeticOperationExprTest.java @@ -16,11 +16,11 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ArithmeticOperationExprTest { +class ArithmeticOperationExprTest { @Test - public void concatOperator_validBasic() { + void concatOperator_validBasic() { // valid type-checking for x + getSomeString() VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.INT).setName("x").build()); @@ -34,7 +34,7 @@ public void concatOperator_validBasic() { } @Test - public void concatOperator_validWithNull() { + void concatOperator_validWithNull() { // Type-checking for String variable x and null object value. VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.STRING).setName("x").build()); @@ -44,7 +44,7 @@ public void concatOperator_validWithNull() { } @Test - public void concatOperator_validWithReferenceType() { + void concatOperator_validWithReferenceType() { // Type-checking for String variable x, Expr variable y. VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.STRING).setName("x").build()); @@ -59,7 +59,7 @@ public void concatOperator_validWithReferenceType() { } @Test - public void concatOperator_invalidVoidType() { + void concatOperator_invalidVoidType() { // throw exception if one of expr is void-type VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.STRING).setName("x").build()); @@ -74,7 +74,7 @@ public void concatOperator_invalidVoidType() { } @Test - public void concatString_invalidNonStringType() { + void concatString_invalidNonStringType() { // throw exception for concat usage if none of exprs is String-type VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.INT).setName("x").build()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArrayExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArrayExprTest.java index a5f47e27d7..98ab1d876a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArrayExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ArrayExprTest.java @@ -18,12 +18,12 @@ import static org.junit.Assert.assertThrows; import com.google.api.generator.test.utils.TestExprBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ArrayExprTest { +class ArrayExprTest { @Test - public void validAnonymousArray_sametype() { + void validAnonymousArray_sametype() { ArrayExpr.Builder exprBuilder = ArrayExpr.builder() .setType(TypeNode.createArrayTypeOf(TypeNode.STRING)) @@ -41,7 +41,7 @@ public void validAnonymousArray_sametype() { } @Test - public void validAnonymousArray_unsetTypeThrows() { + void validAnonymousArray_unsetTypeThrows() { ArrayExpr.Builder exprBuilder = ArrayExpr.builder(); IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> exprBuilder.build()); @@ -49,7 +49,7 @@ public void validAnonymousArray_unsetTypeThrows() { } @Test - public void validAnonymousArray_onlyVariableAndValueExprs() { + void validAnonymousArray_onlyVariableAndValueExprs() { ArrayExpr.Builder exprBuilder = ArrayExpr.builder().setType(TypeNode.createArrayTypeOf(TypeNode.INT)); Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentExprTest.java index b40590f231..7e1cc421f7 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentExprTest.java @@ -19,11 +19,11 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class AssignmentExprTest { +class AssignmentExprTest { @Test - public void assignMatchingValue() { + void assignMatchingValue() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -35,7 +35,7 @@ public void assignMatchingValue() { } @Test - public void assignMismatchedValue() { + void assignMismatchedValue() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -47,7 +47,7 @@ public void assignMismatchedValue() { } @Test - public void assignSubtypeValue() { + void assignSubtypeValue() { Variable variable = Variable.builder() .setName("x") @@ -66,7 +66,7 @@ public void assignSubtypeValue() { } @Test - public void assignMatchingVariable() { + void assignMatchingVariable() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -78,7 +78,7 @@ public void assignMatchingVariable() { } @Test - public void assignNullObjectValue() { + void assignNullObjectValue() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -90,7 +90,7 @@ public void assignNullObjectValue() { } @Test - public void writeAssignmentExpr_nullObjectValuePrimitiveType() { + void writeAssignmentExpr_nullObjectValuePrimitiveType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -102,7 +102,7 @@ public void writeAssignmentExpr_nullObjectValuePrimitiveType() { } @Test - public void writeAssignmentExpr_primitiveToBoxedType() { + void writeAssignmentExpr_primitiveToBoxedType() { // [Constructing] `Boolean x = (boolean) true` Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN_OBJECT).build(); VariableExpr variableExpr = @@ -114,7 +114,7 @@ public void writeAssignmentExpr_primitiveToBoxedType() { } @Test - public void writeAssignmentExpr_boxedToPrimitiveType() { + void writeAssignmentExpr_boxedToPrimitiveType() { // [Constructing] `double x = (Double) y` Variable lVariable = Variable.builder().setName("x").setType(TypeNode.DOUBLE).build(); VariableExpr lVariableExpr = @@ -126,7 +126,7 @@ public void writeAssignmentExpr_boxedToPrimitiveType() { } @Test - public void writeAssignmentExpr_invalidBoxedPrimitiveType() { + void writeAssignmentExpr_invalidBoxedPrimitiveType() { // [Constructing] `double x = (Integer) y` Variable lVariable = Variable.builder().setName("x").setType(TypeNode.DOUBLE).build(); VariableExpr lVariableExpr = @@ -138,7 +138,7 @@ public void writeAssignmentExpr_invalidBoxedPrimitiveType() { } @Test - public void writeAssignmentExpr_validIsDeclFinalVariableExpr() { + void writeAssignmentExpr_validIsDeclFinalVariableExpr() { Variable lVariable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr lVariableExpr = VariableExpr.builder().setVariable(lVariable).setIsDecl(true).setIsFinal(true).build(); @@ -149,7 +149,7 @@ public void writeAssignmentExpr_validIsDeclFinalVariableExpr() { } @Test - public void writeAssignmentExpr_invalidIsNotDeclFinalVariableExpr() { + void writeAssignmentExpr_invalidIsNotDeclFinalVariableExpr() { Variable lVariable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr lVariableExpr = VariableExpr.builder().setVariable(lVariable).setIsDecl(false).setIsFinal(true).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentOperationExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentOperationExprTest.java index 64a6077706..36216e40a6 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentOperationExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/AssignmentOperationExprTest.java @@ -16,12 +16,12 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class AssignmentOperationExprTest { +class AssignmentOperationExprTest { /** ========= Multiply And Assignment Operators: VariableExpr is numeric types ============== */ @Test - public void validMultiplyAndAssignmentOperationExpr_numericMatched() { + void validMultiplyAndAssignmentOperationExpr_numericMatched() { // No need swap test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -30,7 +30,7 @@ public void validMultiplyAndAssignmentOperationExpr_numericMatched() { } @Test - public void validMultiplyAndAssignmentOperationExpr_numericUnmatched() { + void validMultiplyAndAssignmentOperationExpr_numericUnmatched() { // No need swap test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); ValueExpr rhsExpr = createValueExpr(TypeNode.INT, "5"); @@ -39,7 +39,7 @@ public void validMultiplyAndAssignmentOperationExpr_numericUnmatched() { } @Test - public void validMultiplyAndAssignmentOperationExpr_numericMatchedBoxedType() { + void validMultiplyAndAssignmentOperationExpr_numericMatchedBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_integerMatchedBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -48,7 +48,7 @@ public void validMultiplyAndAssignmentOperationExpr_numericMatchedBoxedType() { } @Test - public void validMultiplyAndAssignmentOperationExpr_numericUnmatchedBoxedType() { + void validMultiplyAndAssignmentOperationExpr_numericUnmatchedBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -57,7 +57,7 @@ public void validMultiplyAndAssignmentOperationExpr_numericUnmatchedBoxedType() } @Test - public void validMultiplyAndAssignmentOperationExpr_numericWithFloatType() { + void validMultiplyAndAssignmentOperationExpr_numericWithFloatType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -66,7 +66,7 @@ public void validMultiplyAndAssignmentOperationExpr_numericWithFloatType() { } @Test - public void validMultiplyAndAssignmentOperationExpr_doubleWithIntegerBoxedType() { + void validMultiplyAndAssignmentOperationExpr_doubleWithIntegerBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -75,7 +75,7 @@ public void validMultiplyAndAssignmentOperationExpr_doubleWithIntegerBoxedType() } @Test - public void validMultiplyAndAssignmentOperationExpr_doubleWithLongBoxedType() { + void validMultiplyAndAssignmentOperationExpr_doubleWithLongBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -84,7 +84,7 @@ public void validMultiplyAndAssignmentOperationExpr_doubleWithLongBoxedType() { } @Test - public void validMultiplyAndAssignmentOperationExpr_longWithIntegerBoxedType() { + void validMultiplyAndAssignmentOperationExpr_longWithIntegerBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -93,7 +93,7 @@ public void validMultiplyAndAssignmentOperationExpr_longWithIntegerBoxedType() { } @Test - public void validMultiplyAndAssignmentOperationExpr_integerWithFloatBoxedType() { + void validMultiplyAndAssignmentOperationExpr_integerWithFloatBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -102,7 +102,7 @@ public void validMultiplyAndAssignmentOperationExpr_integerWithFloatBoxedType() } @Test - public void validMultiplyAndAssignmentOperationExpr_validFloatWithLongBoxedType() { + void validMultiplyAndAssignmentOperationExpr_validFloatWithLongBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -111,7 +111,7 @@ public void validMultiplyAndAssignmentOperationExpr_validFloatWithLongBoxedType( } @Test - public void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_booleanBoxedWithNumericType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "y"); @@ -121,7 +121,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanType() { + void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN, "y"); @@ -131,7 +131,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanType() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_numericWithReferenceType() { + void invalidMultiplyAndAssignmentOperationExpr_numericWithReferenceType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_referencedWithNumericType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y"); @@ -141,7 +141,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_numericWithReferenceType() } @Test - public void invalidMultiplyAndAssignmentOperationExpr_NumericWithNewObject() { + void invalidMultiplyAndAssignmentOperationExpr_NumericWithNewObject() { // No Need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -152,7 +152,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_NumericWithNewObject() { /** ==== Multiply And Assignment Operators: LHS data type is boolean and its boxed type ===== */ @Test - public void invalidMultiplyAndAssignmentOperationExpr_booleanWithNumericType() { + void invalidMultiplyAndAssignmentOperationExpr_booleanWithNumericType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -162,7 +162,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_booleanWithNumericType() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_booleanBoxedWithNumericType() { + void invalidMultiplyAndAssignmentOperationExpr_booleanBoxedWithNumericType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "x"); ValueExpr rhsExpr = createValueExpr(TypeNode.INT, "5"); @@ -174,7 +174,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_booleanBoxedWithNumericTyp /** ======== Multiply And Assignment Operators: LHS data type is Integer Box Type ============ */ // RHS should be int, char, short, byte or these types' boxed types. @Test - public void validMultiplyAndAssignmentOperationExpr_integerMatchedBoxedType() { + void validMultiplyAndAssignmentOperationExpr_integerMatchedBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_numericMatchedBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); ValueExpr rhsExpr = createValueExpr(TypeNode.INT, "5"); @@ -183,7 +183,7 @@ public void validMultiplyAndAssignmentOperationExpr_integerMatchedBoxedType() { } @Test - public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortType() { + void validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_numericUnmatchedBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.SHORT, "y"); @@ -192,7 +192,7 @@ public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortType() } @Test - public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortBoxedType() { + void validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_shortBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.SHORT_OBJECT, "y"); @@ -201,7 +201,7 @@ public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithShortBoxedTy } @Test - public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithCharacterBoxedType() { + void validMultiplyAndAssignmentOperationExpr_integerBoxedWithCharacterBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_shortBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR_OBJECT, "y"); @@ -210,7 +210,7 @@ public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithCharacterBox } @Test - public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithByteBoxedType() { + void validMultiplyAndAssignmentOperationExpr_integerBoxedWithByteBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_byteBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BYTE_OBJECT, "y"); @@ -219,7 +219,7 @@ public void validMultiplyAndAssignmentOperationExpr_integerBoxedWithByteBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatType() { + void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_numericWithFloatType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT, "y"); @@ -229,7 +229,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatType( } @Test - public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -239,7 +239,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatBoxed } @Test - public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleType() { + void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_doubleWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE, "y"); @@ -249,7 +249,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleType } @Test - public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "y"); @@ -259,7 +259,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleBoxe } @Test - public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongType() { + void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_longWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG, "y"); @@ -269,7 +269,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongType() } @Test - public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_longBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -281,7 +281,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongBoxedT /** ==== Multiply And Assignment Operators: LHS data type is Float boxed type ====== */ // RHS could be numeric or numeric boxed type, beside double and its boxed type. @Test - public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerType() { + void validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_integerWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); ValueExpr rhsExpr = createValueExpr(TypeNode.INT, "5"); @@ -290,7 +290,7 @@ public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerType() } @Test - public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerBoxedType() { + void validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -299,7 +299,7 @@ public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithIntegerBoxedTy } @Test - public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithCharBoxedType() { + void validMultiplyAndAssignmentOperationExpr_floatBoxedWithCharBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_charBoxedWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR_OBJECT, "y"); @@ -308,7 +308,7 @@ public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithCharBoxedType( } @Test - public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithByteBoxedType() { + void validMultiplyAndAssignmentOperationExpr_floatBoxedWithByteBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BYTE_OBJECT, "y"); @@ -317,7 +317,7 @@ public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithByteBoxedType( } @Test - public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithLongBoxedType() { + void validMultiplyAndAssignmentOperationExpr_floatBoxedWithLongBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -326,7 +326,7 @@ public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithLongBoxedType( } @Test - public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithDoubleBoxedType() { + void validMultiplyAndAssignmentOperationExpr_floatBoxedWithDoubleBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_doubleBoxedWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "y"); @@ -336,7 +336,7 @@ public void validMultiplyAndAssignmentOperationExpr_floatBoxedWithDoubleBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithObjectType() { + void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithObjectType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -346,7 +346,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithObjectType() } @Test - public void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithNullType() { + void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithNullType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); ValueExpr rhsExpr = ValueExpr.createNullExpr(); @@ -356,7 +356,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithNullType() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithReferenceType() { + void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithReferenceType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_referenceWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y"); @@ -368,7 +368,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithReferenceTyp /** ==== Multiply And Assignment Operators: LHS data type is Short/Char/Byte Boxed Type ====== */ // RHS has no valid type. @Test - public void invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithIntegerBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithIntegerBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_integerBoxedWithByteBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BYTE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -378,7 +378,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithIntegerBoxedT } @Test - public void invalidMultiplyAndAssignmentOperationExpr_shortBoxedWithIntegerBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_shortBoxedWithIntegerBoxedType() { // Swap test case in // "validMultiplyAndAssignmentOperationExpr_validCharacterBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.SHORT_OBJECT, "x"); @@ -389,7 +389,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_shortBoxedWithIntegerBoxed } @Test - public void validMultiplyAndAssignmentOperationExpr_characterBoxedWithIntegerBoxedType() { + void validMultiplyAndAssignmentOperationExpr_characterBoxedWithIntegerBoxedType() { // Swap test case in // "validMultiplyAndAssignmentOperationExpr_integerBoxedWithCharacterBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR_OBJECT, "x"); @@ -400,7 +400,7 @@ public void validMultiplyAndAssignmentOperationExpr_characterBoxedWithIntegerBox } @Test - public void invalidMultiplyAndAssignmentOperationExpr_charBoxedWithFloatBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_charBoxedWithFloatBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -410,7 +410,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_charBoxedWithFloatBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithFloatBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithFloatBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_floatBoxedWithByteBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BYTE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -422,7 +422,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_byteBoxedWithFloatBoxedTyp /** ======== Multiply And Assignment Operators: LHS data type is Double Boxed Type ============ */ // RHS could be any numeric type or numeric boxed type. @Test - public void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType() { + void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType() { // Swap test case in // "invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithDoubleBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); @@ -432,7 +432,7 @@ public void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithIntegerBoxedT } @Test - public void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithFloatBoxedType() { + void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithFloatBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithDoubleBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -441,7 +441,7 @@ public void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithFloatBoxedTyp } @Test - public void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithLongBoxedType() { + void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithLongBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -450,7 +450,7 @@ public void validMultiplyAndAssignmentOperationExpr_doubleBoxedWithLongBoxedType } @Test - public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithReferenceType() { + void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithReferenceType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_referenceWithDoubleBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); ValueExpr valueExpr = ValueExpr.withValue(StringObjectValue.withValue("abc")); @@ -460,7 +460,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithReferenceTy } @Test - public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithNullType() { + void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithNullType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); ValueExpr valueExprExpr = ValueExpr.createNullExpr(); @@ -470,7 +470,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithNullType() } @Test - public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithObjectType() { + void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithObjectType() { // No need swap test. VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -481,7 +481,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithObjectType( /** ======== Multiply And Assignment Operators: LHS data type is Long boxed type ============ */ @Test - public void validMultiplyAndAssignmentOperationExpr_longBoxedWithIntegerBoxedType() { + void validMultiplyAndAssignmentOperationExpr_longBoxedWithIntegerBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_integerBoxedWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -490,7 +490,7 @@ public void validMultiplyAndAssignmentOperationExpr_longBoxedWithIntegerBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_floatBoxedWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -500,7 +500,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_floatWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT, "y"); @@ -510,7 +510,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithFloatType() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleBoxedType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_doubleBoxedWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "y"); @@ -520,7 +520,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleBoxedTy } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleType() { // Swap test case in "validMultiplyAndAssignmentOperationExpr_doubleWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE, "y"); @@ -530,7 +530,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithDoubleType() } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithNullType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithNullType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_nullWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); ValueExpr rhsExpr = ValueExpr.createNullExpr(); @@ -540,7 +540,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithNullType() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithObjectType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithObjectType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -550,7 +550,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithObjectType() } @Test - public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithReferenceType() { + void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithReferenceType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_referenceWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y"); @@ -561,7 +561,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_longBoxedWithReferenceType /** ======== Multiply And Assignment Operators: LHS data type is Reference Type ============ */ @Test - public void invalidMultiplyAndAssignmentOperationExpr_referencedWithNumericType() { + void invalidMultiplyAndAssignmentOperationExpr_referencedWithNumericType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_numericWithReferenceType". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE, "y"); @@ -571,7 +571,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_referencedWithNumericType( } @Test - public void invalidMultiplyAndAssignmentOperationExpr_referenceWithFloatBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_referenceWithFloatBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_floatBoxedWithReferenceType". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -581,7 +581,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_referenceWithFloatBoxedTyp } @Test - public void invalidMultiplyAndAssignmentOperationExpr_referenceWithLongBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_referenceWithLongBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_longBoxedWithReferenceType". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -591,7 +591,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_referenceWithLongBoxedType } @Test - public void invalidMultiplyAndAssignmentOperationExpr_referenceWithDoubleBoxedType() { + void invalidMultiplyAndAssignmentOperationExpr_referenceWithDoubleBoxedType() { // Swap test case in "invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithReferenceType". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "y"); @@ -602,7 +602,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_referenceWithDoubleBoxedTy /** =========== Multiply And Assignment Operators: Variable is declaration ================ */ @Test - public void invalidMultiplyAndAssignmentOperationExpr_variableExprIsDecl() { + void invalidMultiplyAndAssignmentOperationExpr_variableExprIsDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr lhsExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -612,7 +612,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_variableExprIsDecl() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_valueExprIsDecl() { + void invalidMultiplyAndAssignmentOperationExpr_valueExprIsDecl() { VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr rhsExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -622,7 +622,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_valueExprIsDecl() { } @Test - public void invalidMultiplyAndAssignmentOperationExpr_variableExprAndValueExprIsDecl() { + void invalidMultiplyAndAssignmentOperationExpr_variableExprAndValueExprIsDecl() { Variable lVariable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr lhsExpr = VariableExpr.builder().setVariable(lVariable).setIsDecl(true).build(); Variable rVariable = Variable.builder().setName("y").setType(TypeNode.INT).build(); @@ -634,7 +634,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_variableExprAndValueExprIs /** ======================= Multiply And Assignment Operators: Void type ===================== */ @Test - public void invalidMultiplyAndAssignmentOperationExpr_voidType() { + void invalidMultiplyAndAssignmentOperationExpr_voidType() { // No need swap case. VariableExpr lhsExprExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); MethodInvocationExpr rhsExpr = @@ -646,7 +646,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_voidType() { /** =================== XOR Assignment Operators: boolean type ======================= */ @Test - public void validXorAssignmentOperationExpr_booleanType() { + void validXorAssignmentOperationExpr_booleanType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN, "y"); @@ -655,7 +655,7 @@ public void validXorAssignmentOperationExpr_booleanType() { } @Test - public void validXorAssignmentOperationExpr_booleanWithBooleanBoxedType() { + void validXorAssignmentOperationExpr_booleanWithBooleanBoxedType() { // Swap case in "validXorAssignmentOperationExpr_booleanBoxedTypeWithUnboxedType. VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "y"); @@ -664,7 +664,7 @@ public void validXorAssignmentOperationExpr_booleanWithBooleanBoxedType() { } @Test - public void validXorAssignmentOperationExpr_booleanBoxedTypeWithUnboxedType() { + void validXorAssignmentOperationExpr_booleanBoxedTypeWithUnboxedType() { // Swap case in "validXorAssignmentOperationExpr_booleanWithBooleanBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN, "y"); @@ -673,7 +673,7 @@ public void validXorAssignmentOperationExpr_booleanBoxedTypeWithUnboxedType() { } @Test - public void validXorAssignmentOperationExpr_booleanBoxedType() { + void validXorAssignmentOperationExpr_booleanBoxedType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "y"); @@ -682,7 +682,7 @@ public void validXorAssignmentOperationExpr_booleanBoxedType() { } @Test - public void invalidXorAssignmentOperationExpr_booleanWithNumericTypes() { + void invalidXorAssignmentOperationExpr_booleanWithNumericTypes() { // Swap case in "invalidXorAssignmentOperationExpr_integerWithBooleanTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -692,7 +692,7 @@ public void invalidXorAssignmentOperationExpr_booleanWithNumericTypes() { } @Test - public void invalidXorAssignmentOperationExpr_booleanWithIntegerBoxedTypes() { + void invalidXorAssignmentOperationExpr_booleanWithIntegerBoxedTypes() { // Swap case in "invalidXorAssignmentOperationExpr_integerBoxedTypeWithBooleanTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -702,7 +702,7 @@ public void invalidXorAssignmentOperationExpr_booleanWithIntegerBoxedTypes() { } @Test - public void invalidXorAssignmentOperationExpr_booleanWithReferencedTypes() { + void invalidXorAssignmentOperationExpr_booleanWithReferencedTypes() { // Swap case in "invalidXorAssignmentOperationExpr_referencedTypeWithBooleanTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y"); @@ -712,7 +712,7 @@ public void invalidXorAssignmentOperationExpr_booleanWithReferencedTypes() { } @Test - public void invalidXorAssignmentOperationExpr_booleanWithNullTypes() { + void invalidXorAssignmentOperationExpr_booleanWithNullTypes() { // No valid swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); ValueExpr rhsExpr = ValueExpr.createNullExpr(); @@ -722,7 +722,7 @@ public void invalidXorAssignmentOperationExpr_booleanWithNullTypes() { } @Test - public void invalidXorAssignmentOperationExpr_booleanWithNewObjectTypes() { + void invalidXorAssignmentOperationExpr_booleanWithNewObjectTypes() { // No valid swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -733,7 +733,7 @@ public void invalidXorAssignmentOperationExpr_booleanWithNewObjectTypes() { /** ======= XOR Assignment Operators: LHS is non-floating-point numeric types ========= */ @Test - public void validXorAssignmentOperationExpr_integerWithCharType() { + void validXorAssignmentOperationExpr_integerWithCharType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR, "y"); @@ -742,7 +742,7 @@ public void validXorAssignmentOperationExpr_integerWithCharType() { } @Test - public void validXorAssignmentOperationExpr_integerWithIntegerType() { + void validXorAssignmentOperationExpr_integerWithIntegerType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -751,7 +751,7 @@ public void validXorAssignmentOperationExpr_integerWithIntegerType() { } @Test - public void validXorAssignmentOperationExpr_integerWithByteType() { + void validXorAssignmentOperationExpr_integerWithByteType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BYTE, "y"); @@ -760,7 +760,7 @@ public void validXorAssignmentOperationExpr_integerWithByteType() { } @Test - public void validXorAssignmentOperationExpr_integerWithShortType() { + void validXorAssignmentOperationExpr_integerWithShortType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.SHORT, "y"); @@ -769,7 +769,7 @@ public void validXorAssignmentOperationExpr_integerWithShortType() { } @Test - public void validXorAssignmentOperationExpr_integerWithLongType() { + void validXorAssignmentOperationExpr_integerWithLongType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG, "y"); @@ -778,7 +778,7 @@ public void validXorAssignmentOperationExpr_integerWithLongType() { } @Test - public void validXorAssignmentOperationExpr_byteWithIntegerBoxedType() { + void validXorAssignmentOperationExpr_byteWithIntegerBoxedType() { // Swap case in "validXorAssignmentOperationExpr_integerBoxedTypeWithByteType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BYTE, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -787,7 +787,7 @@ public void validXorAssignmentOperationExpr_byteWithIntegerBoxedType() { } @Test - public void validXorAssignmentOperationExpr_charWithIntegerType() { + void validXorAssignmentOperationExpr_charWithIntegerType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -796,7 +796,7 @@ public void validXorAssignmentOperationExpr_charWithIntegerType() { } @Test - public void validXorAssignmentOperationExpr_shortWithIntegerType() { + void validXorAssignmentOperationExpr_shortWithIntegerType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.SHORT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -805,7 +805,7 @@ public void validXorAssignmentOperationExpr_shortWithIntegerType() { } @Test - public void validXorAssignmentOperationExpr_longWithIntegerType() { + void validXorAssignmentOperationExpr_longWithIntegerType() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -814,7 +814,7 @@ public void validXorAssignmentOperationExpr_longWithIntegerType() { } @Test - public void validXorAssignmentOperationExpr_charWithIntegerBoxedType() { + void validXorAssignmentOperationExpr_charWithIntegerBoxedType() { // Swap case in . VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -823,7 +823,7 @@ public void validXorAssignmentOperationExpr_charWithIntegerBoxedType() { } @Test - public void validXorAssignmentOperationExpr_longWithByteBoxedType() { + void validXorAssignmentOperationExpr_longWithByteBoxedType() { // Swap case in . VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BYTE_OBJECT, "y"); @@ -832,7 +832,7 @@ public void validXorAssignmentOperationExpr_longWithByteBoxedType() { } @Test - public void validXorAssignmentOperationExpr_integerWithLongBoxedType() { + void validXorAssignmentOperationExpr_integerWithLongBoxedType() { // Swap case in . VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -841,7 +841,7 @@ public void validXorAssignmentOperationExpr_integerWithLongBoxedType() { } @Test - public void invalidXorAssignmentOperationExpr_integerWithDoubleTypes() { + void invalidXorAssignmentOperationExpr_integerWithDoubleTypes() { // Swap case in "invalidXorAssignmentOperationExpr_doubleWithIntegerTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE, "y"); @@ -851,7 +851,7 @@ public void invalidXorAssignmentOperationExpr_integerWithDoubleTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerWithDoubleBoxedTypes() { + void invalidXorAssignmentOperationExpr_integerWithDoubleBoxedTypes() { // Swap case in "invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "y"); @@ -861,7 +861,7 @@ public void invalidXorAssignmentOperationExpr_integerWithDoubleBoxedTypes() { } @Test - public void invalidXorAssignmentOperationExpr_charWithFloatTypes() { + void invalidXorAssignmentOperationExpr_charWithFloatTypes() { // Swap case in "invalidXorAssignmentOperationExpr_floatWithCharTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT, "y"); @@ -871,7 +871,7 @@ public void invalidXorAssignmentOperationExpr_charWithFloatTypes() { } @Test - public void invalidXorAssignmentOperationExpr_charWithFloatBoxedTypes() { + void invalidXorAssignmentOperationExpr_charWithFloatBoxedTypes() { // Swap case in "invalidXorAssignmentOperationExpr_floatBoxedWithCharTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -881,7 +881,7 @@ public void invalidXorAssignmentOperationExpr_charWithFloatBoxedTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerWithBooleanTypes() { + void invalidXorAssignmentOperationExpr_integerWithBooleanTypes() { // Swap case in "invalidXorAssignmentOperationExpr_booleanWithNumericTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN, "y"); @@ -891,7 +891,7 @@ public void invalidXorAssignmentOperationExpr_integerWithBooleanTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerWithNullTypes() { + void invalidXorAssignmentOperationExpr_integerWithNullTypes() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); ValueExpr rhsExpr = ValueExpr.createNullExpr(); @@ -901,7 +901,7 @@ public void invalidXorAssignmentOperationExpr_integerWithNullTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerWithReferenceTypes() { + void invalidXorAssignmentOperationExpr_integerWithReferenceTypes() { // Swap case in invalidXorAssignmentOperationExpr_referenceWithCharTypes. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y"); @@ -912,7 +912,7 @@ public void invalidXorAssignmentOperationExpr_integerWithReferenceTypes() { /** ============= XOR Assignment Operators: LHS is integer boxed type ================= */ @Test - public void validXorAssignmentOperationExpr_integerBoxedTypeWithIntegerType() { + void validXorAssignmentOperationExpr_integerBoxedTypeWithIntegerType() { // Swap case in "validXorAssignmentOperationExpr_charWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -921,7 +921,7 @@ public void validXorAssignmentOperationExpr_integerBoxedTypeWithIntegerType() { } @Test - public void validXorAssignmentOperationExpr_integerBoxedTypeWithCharType() { + void validXorAssignmentOperationExpr_integerBoxedTypeWithCharType() { // Swap case in validXorAssignmentOperationExpr_charWithIntegerBoxedType. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR, "y"); @@ -930,7 +930,7 @@ public void validXorAssignmentOperationExpr_integerBoxedTypeWithCharType() { } @Test - public void validXorAssignmentOperationExpr_integerBoxedTypeWithByteType() { + void validXorAssignmentOperationExpr_integerBoxedTypeWithByteType() { // Swap case in "validXorAssignmentOperationExpr_byteWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BYTE, "y"); @@ -939,7 +939,7 @@ public void validXorAssignmentOperationExpr_integerBoxedTypeWithByteType() { } @Test - public void validXorAssignmentOperationExpr_integerBoxedTypeWithLongBoxedType() { + void validXorAssignmentOperationExpr_integerBoxedTypeWithLongBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_longBoxedTypeWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "y"); @@ -948,7 +948,7 @@ public void validXorAssignmentOperationExpr_integerBoxedTypeWithLongBoxedType() } @Test - public void validXorAssignmentOperationExpr_integerBoxedTypeWithShortBoxedType() { + void validXorAssignmentOperationExpr_integerBoxedTypeWithShortBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_shortBoxedTypeWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.SHORT_OBJECT, "y"); @@ -957,7 +957,7 @@ public void validXorAssignmentOperationExpr_integerBoxedTypeWithShortBoxedType() } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatType() { + void invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatType() { // Swap case in "invalidXorAssignmentOperationExpr_floatWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT, "y"); @@ -967,7 +967,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatType() { } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatBoxedType() { + void invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_floatBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "y"); @@ -977,7 +977,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatBoxedType } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleType() { + void invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleType() { // Swap case in "invalidXorAssignmentOperationExpr_doubleWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE, "y"); @@ -987,7 +987,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleType() { } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleBoxedType() { + void invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "y"); @@ -998,7 +998,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleBoxedTyp /** =========== XOR Assignment Operators: LHS is floating-point type =============== */ @Test - public void invalidXorAssignmentOperationExpr_floatWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_floatWithIntegerBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1008,7 +1008,7 @@ public void invalidXorAssignmentOperationExpr_floatWithIntegerBoxedType() { } @Test - public void invalidXorAssignmentOperationExpr_floatBoxedWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_floatBoxedWithIntegerBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_integerBoxedTypeWithFloatBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1018,7 +1018,7 @@ public void invalidXorAssignmentOperationExpr_floatBoxedWithIntegerBoxedType() { } @Test - public void invalidXorAssignmentOperationExpr_doubleWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_doubleWithIntegerBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1028,7 +1028,7 @@ public void invalidXorAssignmentOperationExpr_doubleWithIntegerBoxedType() { } @Test - public void invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_integerBoxedTypeWithDoubleBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1038,7 +1038,7 @@ public void invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerBoxedType() } @Test - public void invalidXorAssignmentOperationExpr_doubleWithIntegerTypes() { + void invalidXorAssignmentOperationExpr_doubleWithIntegerTypes() { // Swap case in "invalidXorAssignmentOperationExpr_integerWithDoubleTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -1048,7 +1048,7 @@ public void invalidXorAssignmentOperationExpr_doubleWithIntegerTypes() { } @Test - public void invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerTypes() { + void invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerTypes() { // Swap case in "invalidXorAssignmentOperationExpr_integerWithDoubleBoxedTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -1058,7 +1058,7 @@ public void invalidXorAssignmentOperationExpr_doubleBoxedWithIntegerTypes() { } @Test - public void invalidXorAssignmentOperationExpr_floatWithCharTypes() { + void invalidXorAssignmentOperationExpr_floatWithCharTypes() { // Swap case in "invalidXorAssignmentOperationExpr_charWithFloatTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR, "y"); @@ -1068,7 +1068,7 @@ public void invalidXorAssignmentOperationExpr_floatWithCharTypes() { } @Test - public void invalidXorAssignmentOperationExpr_floatBoxedTypeWithCharTypes() { + void invalidXorAssignmentOperationExpr_floatBoxedTypeWithCharTypes() { // Swap case in "invalidXorAssignmentOperationExpr_charWithFloatBoxedTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR, "y"); @@ -1078,7 +1078,7 @@ public void invalidXorAssignmentOperationExpr_floatBoxedTypeWithCharTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithBooleanTypes() { + void invalidXorAssignmentOperationExpr_integerBoxedTypeWithBooleanTypes() { // Swap case in "invalidXorAssignmentOperationExpr_booleanWithIntegerBoxedTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN, "y"); @@ -1088,7 +1088,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedTypeWithBooleanTypes() } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedWithNullTypes() { + void invalidXorAssignmentOperationExpr_integerBoxedWithNullTypes() { // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); ValueExpr rhsExpr = ValueExpr.createNullExpr(); @@ -1098,7 +1098,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedWithNullTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedWithReferenceTypes() { + void invalidXorAssignmentOperationExpr_integerBoxedWithReferenceTypes() { // Swap case in invalidXorAssignmentOperationExpr_referenceWithIntegerBoxedTypes. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y"); @@ -1108,7 +1108,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedWithReferenceTypes() { } @Test - public void invalidXorAssignmentOperationExpr_integerBoxedWithNewObjectTypes() { + void invalidXorAssignmentOperationExpr_integerBoxedWithNewObjectTypes() { // No swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -1119,7 +1119,7 @@ public void invalidXorAssignmentOperationExpr_integerBoxedWithNewObjectTypes() { /** ======= XOR Assignment Operators: LHS is non integer numeric boxed type =========== */ @Test - public void invalidXorAssignmentOperationExpr_longBoxedTypeWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_longBoxedTypeWithIntegerBoxedType() { // Swap case in "validXorAssignmentOperationExpr_integerBoxedTypeWithLongBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.LONG_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1129,7 +1129,7 @@ public void invalidXorAssignmentOperationExpr_longBoxedTypeWithIntegerBoxedType( } @Test - public void invalidXorAssignmentOperationExpr_shortBoxedTypeWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_shortBoxedTypeWithIntegerBoxedType() { // Swap case in "validXorAssignmentOperationExpr_integerBoxedTypeWithShortBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.SHORT_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1139,7 +1139,7 @@ public void invalidXorAssignmentOperationExpr_shortBoxedTypeWithIntegerBoxedType } @Test - public void invalidXorAssignmentOperationExpr_charBoxedTypeWithIntegerType() { + void invalidXorAssignmentOperationExpr_charBoxedTypeWithIntegerType() { // No swap case need. VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -1149,7 +1149,7 @@ public void invalidXorAssignmentOperationExpr_charBoxedTypeWithIntegerType() { } @Test - public void invalidXorAssignmentOperationExpr_byteBoxedTypeWithIntegerType() { + void invalidXorAssignmentOperationExpr_byteBoxedTypeWithIntegerType() { // No swap case need. VariableExpr lhsExpr = createVariableExpr(TypeNode.BYTE_OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -1160,7 +1160,7 @@ public void invalidXorAssignmentOperationExpr_byteBoxedTypeWithIntegerType() { /** ============= XOR Assignment Operators: LHS is non primitive type ================= */ @Test - public void invalidXorAssignmentOperationExpr_referencedTypeWithBooleanTypes() { + void invalidXorAssignmentOperationExpr_referencedTypeWithBooleanTypes() { // Swap case in "invalidXorAssignmentOperationExpr_booleanWithReferencedTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.BOOLEAN, "y"); @@ -1170,7 +1170,7 @@ public void invalidXorAssignmentOperationExpr_referencedTypeWithBooleanTypes() { } @Test - public void invalidXorAssignmentOperationExpr_referencedTypeWithCharTypes() { + void invalidXorAssignmentOperationExpr_referencedTypeWithCharTypes() { // Swap case in "invalidXorAssignmentOperationExpr_integerWithReferencedTypes". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.CHAR, "y"); @@ -1180,7 +1180,7 @@ public void invalidXorAssignmentOperationExpr_referencedTypeWithCharTypes() { } @Test - public void invalidXorAssignmentOperationExpr_ReferenceTypeWithIntegerBoxedType() { + void invalidXorAssignmentOperationExpr_ReferenceTypeWithIntegerBoxedType() { // Swap case in "invalidXorAssignmentOperationExpr_referenceWithIntegerBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "y"); @@ -1190,7 +1190,7 @@ public void invalidXorAssignmentOperationExpr_ReferenceTypeWithIntegerBoxedType( } @Test - public void invalidXorAssignmentOperationExpr_voidType() { + void invalidXorAssignmentOperationExpr_voidType() { // No need swap case. VariableExpr lhsExprExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); MethodInvocationExpr rhsExpr = @@ -1202,7 +1202,7 @@ public void invalidXorAssignmentOperationExpr_voidType() { /** =========== XOR Assignment Operators: Variable is declaration ================ */ @Test - public void invalidXorAssignmentOperationExpr_variableExprIsDecl() { + void invalidXorAssignmentOperationExpr_variableExprIsDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr lhsExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); VariableExpr rhsExpr = createVariableExpr(TypeNode.INT, "y"); @@ -1212,7 +1212,7 @@ public void invalidXorAssignmentOperationExpr_variableExprIsDecl() { } @Test - public void invalidXorAssignmentOperationExpr_valueExprIsDecl() { + void invalidXorAssignmentOperationExpr_valueExprIsDecl() { VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr rhsExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -1222,7 +1222,7 @@ public void invalidXorAssignmentOperationExpr_valueExprIsDecl() { } @Test - public void invalidXorAssignmentOperationExpr_variableExprAndValueExprIsDecl() { + void invalidXorAssignmentOperationExpr_variableExprAndValueExprIsDecl() { Variable lVariable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr lhsExpr = VariableExpr.builder().setVariable(lVariable).setIsDecl(true).build(); Variable rVariable = Variable.builder().setName("y").setType(TypeNode.INT).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/CastExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/CastExprTest.java index 04bb8a05ca..4d79d3c7ac 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/CastExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/CastExprTest.java @@ -16,11 +16,11 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CastExprTest { +class CastExprTest { @Test - public void validCastExpr_basic() { + void validCastExpr_basic() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder() @@ -31,7 +31,7 @@ public void validCastExpr_basic() { } @Test - public void validCastExpr_basicNull() { + void validCastExpr_basicNull() { CastExpr.builder() .setType(TypeNode.withReference(ConcreteReference.withClazz(Object.class))) .setExpr(ValueExpr.createNullExpr()) @@ -40,7 +40,7 @@ public void validCastExpr_basicNull() { } @Test - public void validCastExpr_basicPrimitiveSame() { + void validCastExpr_basicPrimitiveSame() { Variable variable = Variable.builder().setName("x").setType(TypeNode.LONG).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder().setType(TypeNode.LONG).setExpr(variableExpr).build(); @@ -48,7 +48,7 @@ public void validCastExpr_basicPrimitiveSame() { } @Test - public void validCastExpr_basicPrimitiveBoolean() { + void validCastExpr_basicPrimitiveBoolean() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder().setType(TypeNode.BOOLEAN).setExpr(variableExpr).build(); @@ -56,7 +56,7 @@ public void validCastExpr_basicPrimitiveBoolean() { } @Test - public void validCastExpr_basicPrimitiveNarrowing() { + void validCastExpr_basicPrimitiveNarrowing() { Variable variable = Variable.builder().setName("x").setType(TypeNode.LONG).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder().setType(TypeNode.INT).setExpr(variableExpr).build(); @@ -70,7 +70,7 @@ public void validCastExpr_basicPrimitiveNarrowing() { } @Test - public void validCastExpr_basicPrimitiveWidening() { + void validCastExpr_basicPrimitiveWidening() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder().setType(TypeNode.LONG).setExpr(variableExpr).build(); @@ -83,21 +83,21 @@ public void validCastExpr_basicPrimitiveWidening() { } @Test - public void validCastExpr_castPrimitiveToBoxedType() { + void validCastExpr_castPrimitiveToBoxedType() { PrimitiveValue intValue = PrimitiveValue.builder().setValue("3").setType(TypeNode.INT).build(); ValueExpr valueExpr = ValueExpr.withValue(intValue); CastExpr.builder().setType(TypeNode.INT_OBJECT).setExpr(valueExpr).build(); } @Test - public void validCastExpr_castBoxedTypeToPrimitive() { + void validCastExpr_castBoxedTypeToPrimitive() { Variable variable = Variable.builder().setName("x").setType(TypeNode.DOUBLE_OBJECT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder().setType(TypeNode.DOUBLE).setExpr(variableExpr).build(); } @Test - public void validCastExpr_booleanToBoxedType() { + void validCastExpr_booleanToBoxedType() { PrimitiveValue booleanValue = PrimitiveValue.builder().setValue("true").setType(TypeNode.BOOLEAN).build(); ValueExpr valueExpr = ValueExpr.withValue(booleanValue); @@ -105,14 +105,14 @@ public void validCastExpr_booleanToBoxedType() { } @Test - public void validCastExpr_castBooleanToPrimitive() { + void validCastExpr_castBooleanToPrimitive() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN_OBJECT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr.builder().setType(TypeNode.BOOLEAN).setExpr(variableExpr).build(); } @Test - public void invalidCastExpr_castBoxedPrimitiveArray() { + void invalidCastExpr_castBoxedPrimitiveArray() { TypeNode intArray = TypeNode.builder().setTypeKind(TypeNode.TypeKind.INT).setIsArray(true).build(); TypeNode integerArray = @@ -129,7 +129,7 @@ public void invalidCastExpr_castBoxedPrimitiveArray() { } @Test - public void invalidCastExpr_castObjectToPrimitive() { + void invalidCastExpr_castObjectToPrimitive() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThrows( @@ -138,7 +138,7 @@ public void invalidCastExpr_castObjectToPrimitive() { } @Test - public void invalidCastExpr_castPrimitiveToObject() { + void invalidCastExpr_castPrimitiveToObject() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThrows( @@ -151,7 +151,7 @@ public void invalidCastExpr_castPrimitiveToObject() { } @Test - public void invalidCastExpr_castBooleanToNumeric() { + void invalidCastExpr_castBooleanToNumeric() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThrows( @@ -160,7 +160,7 @@ public void invalidCastExpr_castBooleanToNumeric() { } @Test - public void invalidCastExpr_castNumericToBoolean() { + void invalidCastExpr_castNumericToBoolean() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThrows( @@ -169,7 +169,7 @@ public void invalidCastExpr_castNumericToBoolean() { } @Test - public void invalidCastExpr_castToVoidType() { + void invalidCastExpr_castToVoidType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThrows( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ClassDefinitionTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ClassDefinitionTest.java index d08ad60225..9b7015862d 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ClassDefinitionTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ClassDefinitionTest.java @@ -18,12 +18,12 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ClassDefinitionTest { +class ClassDefinitionTest { @Test - public void validClassDefinition_basicWithCommentsAndHeader() { + void validClassDefinition_basicWithCommentsAndHeader() { LineComment lineComment = LineComment.withComment("AUTO-GENERATED DOCUMENTATION AND CLASS"); JavaDocComment javaDocComment = JavaDocComment.builder() @@ -45,7 +45,7 @@ public void validClassDefinition_basicWithCommentsAndHeader() { } @Test - public void validClassDefinition_exprCommentAndBlockStatements() { + void validClassDefinition_exprCommentAndBlockStatements() { ClassDefinition.builder() .setName("LibraryServiceStub") .setIsNested(true) @@ -74,7 +74,7 @@ public void validClassDefinition_exprCommentAndBlockStatements() { } @Test - public void validClassDefinition_nestedBasic() { + void validClassDefinition_nestedBasic() { ClassDefinition.builder() .setName("LibraryServiceStub") .setIsNested(true) @@ -92,7 +92,7 @@ public void validClassDefinition_nestedBasic() { } @Test - public void validClassDefinition_withAnnotationsExtendsAndImplements() { + void validClassDefinition_withAnnotationsExtendsAndImplements() { ClassDefinition.builder() .setPackageString("com.google.example.library.v1.stub") .setName("LibraryServiceStub") @@ -110,7 +110,7 @@ public void validClassDefinition_withAnnotationsExtendsAndImplements() { } @Test - public void validClassDefinition_statementsAndMethods() { + void validClassDefinition_statementsAndMethods() { List statements = Arrays.asList( ExprStatement.withExpr(createAssignmentExpr()), @@ -149,7 +149,7 @@ public void validClassDefinition_statementsAndMethods() { } @Test - public void invalidClassDefinition_nestedWithFileHeader() { + void invalidClassDefinition_nestedWithFileHeader() { assertThrows( IllegalStateException.class, () -> { @@ -164,7 +164,7 @@ public void invalidClassDefinition_nestedWithFileHeader() { } @Test - public void invalidClassDefinition_implementsNullType() { + void invalidClassDefinition_implementsNullType() { assertThrows( IllegalStateException.class, () -> { @@ -178,7 +178,7 @@ public void invalidClassDefinition_implementsNullType() { } @Test - public void invalidClassDefinition_outerClassMissingPackage() { + void invalidClassDefinition_outerClassMissingPackage() { assertThrows( NullPointerException.class, () -> { @@ -190,7 +190,7 @@ public void invalidClassDefinition_outerClassMissingPackage() { } @Test - public void invalidClassDefinition_outerClassStatic() { + void invalidClassDefinition_outerClassStatic() { assertThrows( IllegalStateException.class, () -> { @@ -204,7 +204,7 @@ public void invalidClassDefinition_outerClassStatic() { } @Test - public void invalidClassDefinition_outerClassPrivate() { + void invalidClassDefinition_outerClassPrivate() { assertThrows( IllegalStateException.class, () -> { @@ -217,7 +217,7 @@ public void invalidClassDefinition_outerClassPrivate() { } @Test - public void invalidClassDefinition_extendsPrimitiveType() { + void invalidClassDefinition_extendsPrimitiveType() { assertThrows( IllegalStateException.class, () -> { @@ -231,7 +231,7 @@ public void invalidClassDefinition_extendsPrimitiveType() { } @Test - public void invalidClassDefinition_extendsNullType() { + void invalidClassDefinition_extendsNullType() { assertThrows( IllegalStateException.class, () -> { @@ -245,7 +245,7 @@ public void invalidClassDefinition_extendsNullType() { } @Test - public void invalidClassDefinition_abstractFinal() { + void invalidClassDefinition_abstractFinal() { assertThrows( IllegalStateException.class, () -> { @@ -261,7 +261,7 @@ public void invalidClassDefinition_abstractFinal() { } @Test - public void invalidClassDefinition_implementsPrimtiveType() { + void invalidClassDefinition_implementsPrimtiveType() { assertThrows( IllegalStateException.class, () -> { @@ -275,7 +275,7 @@ public void invalidClassDefinition_implementsPrimtiveType() { } @Test - public void invalidClassDefinition_extendsImplementsSameType() { + void invalidClassDefinition_extendsImplementsSameType() { TypeNode cloneableType = TypeNode.withReference(ConcreteReference.withClazz(Cloneable.class)); assertThrows( IllegalStateException.class, @@ -294,7 +294,7 @@ public void invalidClassDefinition_extendsImplementsSameType() { } @Test - public void invalidClassDefinition_assignmentWithUnscopedVariableExprStatement() { + void invalidClassDefinition_assignmentWithUnscopedVariableExprStatement() { Variable variable = createVariable("x", TypeNode.INT); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -319,7 +319,7 @@ public void invalidClassDefinition_assignmentWithUnscopedVariableExprStatement() } @Test - public void invalidClassDefinition_unscopedVariableExprStatement() { + void invalidClassDefinition_unscopedVariableExprStatement() { List statements = Arrays.asList( ExprStatement.withExpr(createAssignmentExpr()), @@ -341,7 +341,7 @@ public void invalidClassDefinition_unscopedVariableExprStatement() { } @Test - public void invalidClassDefinition_badStatementType() { + void invalidClassDefinition_badStatementType() { List statements = Arrays.asList(createForStatement()); assertThrows( IllegalStateException.class, diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ConcreteReferenceTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ConcreteReferenceTest.java index 6fdc65a937..f0786fbe3c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ConcreteReferenceTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ConcreteReferenceTest.java @@ -23,18 +23,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ConcreteReferenceTest { +class ConcreteReferenceTest { @Test - public void basicConcreteReference() { + void basicConcreteReference() { Reference reference = ConcreteReference.builder().setClazz(Integer.class).build(); assertEquals(Integer.class.getSimpleName(), reference.name()); assertFalse(reference.isStaticImport()); } @Test - public void basicConcreteReference_setIsStaticImport() { + void basicConcreteReference_setIsStaticImport() { Reference reference = ConcreteReference.builder().setClazz(Integer.class).setIsStaticImport(true).build(); assertEquals(Integer.class.getSimpleName(), reference.name()); @@ -42,14 +42,14 @@ public void basicConcreteReference_setIsStaticImport() { } @Test - public void basicConcreteReference_nested() { + void basicConcreteReference_nested() { Reference reference = ConcreteReference.builder().setClazz(Map.Entry.class).build(); assertEquals("Map.Entry", reference.name()); assertFalse(reference.isStaticImport()); } @Test - public void basicConcreteReference_nestedAndStaticImport() { + void basicConcreteReference_nestedAndStaticImport() { Reference reference = ConcreteReference.builder().setClazz(Map.Entry.class).setIsStaticImport(true).build(); assertEquals(Map.Entry.class.getSimpleName(), reference.name()); @@ -57,7 +57,7 @@ public void basicConcreteReference_nestedAndStaticImport() { } @Test - public void parameterizedConcreteReference() { + void parameterizedConcreteReference() { Reference reference = ConcreteReference.builder() .setClazz(HashMap.class) @@ -71,7 +71,7 @@ public void parameterizedConcreteReference() { } @Test - public void nestedParameterizedConcreteReference() { + void nestedParameterizedConcreteReference() { Reference mapReference = ConcreteReference.builder() .setClazz(HashMap.class) @@ -96,7 +96,7 @@ public void nestedParameterizedConcreteReference() { } @Test - public void isSupertype_basic() { + void isSupertype_basic() { assertTrue(TypeNode.STRING.isSupertypeOrEquals(TypeNode.STRING)); assertFalse(TypeNode.INT.isSupertypeOrEquals(TypeNode.STRING)); assertFalse(TypeNode.STRING.isSupertypeOrEquals(TypeNode.INT)); @@ -109,7 +109,7 @@ public void isSupertype_basic() { } @Test - public void isSupertype_nestedGenerics() { + void isSupertype_nestedGenerics() { Reference stringRef = ConcreteReference.withClazz(String.class); TypeNode typeOne = TypeNode.withReference( @@ -142,7 +142,7 @@ public void isSupertype_nestedGenerics() { } @Test - public void wildcards() { + void wildcards() { assertEquals(ConcreteReference.wildcard().name(), "?"); assertEquals( "? extends String", @@ -150,7 +150,7 @@ public void wildcards() { } @Test - public void isAssignableFrom_concreteRef() { + void isAssignableFrom_concreteRef() { assertFalse( ConcreteReference.withClazz(List.class) .isAssignableFrom(ConcreteReference.withClazz(Map.class))); @@ -195,7 +195,7 @@ public void isAssignableFrom_concreteRef() { } @Test - public void isAssignableFrom_vaporRef() { + void isAssignableFrom_vaporRef() { assertFalse( ConcreteReference.withClazz(List.class) .isAssignableFrom( @@ -207,7 +207,7 @@ public void isAssignableFrom_vaporRef() { } @Test - public void isAssignableFrom_vaporRefWithConcreteRefSupertype() { + void isAssignableFrom_vaporRefWithConcreteRefSupertype() { assertTrue( ConcreteReference.withClazz(List.class) .isAssignableFrom( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/EnumRefExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/EnumRefExprTest.java index 436f00a536..6cc79fe697 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/EnumRefExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/EnumRefExprTest.java @@ -16,25 +16,25 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class EnumRefExprTest { +class EnumRefExprTest { @Test - public void validEnumRefExpr_basic() { + void validEnumRefExpr_basic() { TypeNode enumType = TypeNode.withReference(ConcreteReference.withClazz(TypeNode.TypeKind.class)); EnumRefExpr.builder().setName("VOID").setType(enumType).build(); } @Test - public void invalidEnumRefExpr_primitiveType() { + void invalidEnumRefExpr_primitiveType() { assertThrows( IllegalStateException.class, () -> EnumRefExpr.builder().setName("VOID").setType(TypeNode.INT).build()); } @Test - public void invalidEnumRefExpr_nullType() { + void invalidEnumRefExpr_nullType() { assertThrows( IllegalStateException.class, () -> EnumRefExpr.builder().setName("VOID").setType(TypeNode.NULL).build()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java index d97a3ddce3..b87711d645 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ExprStatementTest.java @@ -17,12 +17,12 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ExprStatementTest { +class ExprStatementTest { @Test - public void validExprStatement_method() { + void validExprStatement_method() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -39,13 +39,13 @@ public void validExprStatement_method() { } @Test - public void validExprStatement_variable() { + void validExprStatement_variable() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); assertValidExprStatement(VariableExpr.builder().setVariable(variable).setIsDecl(true).build()); } @Test - public void validExprStatement_assignment() { + void validExprStatement_assignment() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -59,20 +59,20 @@ public void validExprStatement_assignment() { } @Test - public void validExprStatement_throw() { + void validExprStatement_throw() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); assertValidExprStatement(ThrowExpr.builder().setType(npeType).build()); } @Test - public void validExprStatement_return() { + void validExprStatement_return() { assertValidExprStatement( ReturnExpr.withExpr(ValueExpr.withValue(StringObjectValue.withValue("asdf")))); } @Test - public void validExprStatement_unaryOperation() { + void validExprStatement_unaryOperation() { assertValidExprStatement( UnaryOperationExpr.postfixIncrementWithExpr( VariableExpr.withVariable( @@ -80,7 +80,7 @@ public void validExprStatement_unaryOperation() { } @Test - public void validExprStatement_assignmentOperationExpr() { + void validExprStatement_assignmentOperationExpr() { VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setName("i").setType(TypeNode.INT).build()); ValueExpr rhsExpr = @@ -89,21 +89,21 @@ public void validExprStatement_assignmentOperationExpr() { } @Test - public void invalidExprStatement_variable() { + void invalidExprStatement_variable() { Variable variable = Variable.builder().setType(TypeNode.INT).setName("libraryClient").build(); VariableExpr varExpr = VariableExpr.builder().setVariable(variable).build(); assertInvalidExprStatement(varExpr); } @Test - public void invalidExprStatement_value() { + void invalidExprStatement_value() { Value value = PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build(); ValueExpr valueExpr = ValueExpr.builder().setValue(value).build(); assertInvalidExprStatement(valueExpr); } @Test - public void invalidExprStatement_logicalNotUnaryOperator() { + void invalidExprStatement_logicalNotUnaryOperator() { Expr logicalNotExpr = UnaryOperationExpr.logicalNotWithExpr( VariableExpr.withVariable( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ForStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ForStatementTest.java index 569eebb3c0..5d44157e73 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ForStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ForStatementTest.java @@ -18,12 +18,12 @@ import static org.junit.Assert.assertThrows; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ForStatementTest { +class ForStatementTest { @Test - public void validForStatement() { + void validForStatement() { Variable variable = Variable.builder().setName("str").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -41,7 +41,7 @@ public void validForStatement() { } @Test - public void invalidForStatement() { + void invalidForStatement() { Variable variable = Variable.builder().setName("str").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/GeneralForStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/GeneralForStatementTest.java index 4d14429c1a..9b9d3af6ae 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/GeneralForStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/GeneralForStatementTest.java @@ -18,13 +18,13 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GeneralForStatementTest { +class GeneralForStatementTest { /** ============================== incrementWith ====================================== */ @Test // validGeneralForStatement_basicIsDecl tests declare a variable inside in initialization expr. - public void validGeneralForStatement_basicIsDecl() { + void validGeneralForStatement_basicIsDecl() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -41,7 +41,7 @@ public void validGeneralForStatement_basicIsDecl() { @Test // validGeneralForStatement_basicIsNotDecl tests assigning a method-level local variable in // initialization expr. - public void validGeneralForStatement_basicIsNotDecl() { + void validGeneralForStatement_basicIsNotDecl() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(false).build(); @@ -57,7 +57,7 @@ public void validGeneralForStatement_basicIsNotDecl() { @Test // validGeneralForStatement_emptyBody tests set empty body in update expr. - public void validGeneralForStatement_emptyBody() { + void validGeneralForStatement_emptyBody() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(false).build(); @@ -74,7 +74,7 @@ public void validGeneralForStatement_emptyBody() { @Test // validForStatement_privateNotIsDeclVariable tests assigning an instance variable with private // scope. - public void validForStatement_privateNotIsDeclVariable() { + void validForStatement_privateNotIsDeclVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -91,9 +91,9 @@ public void validForStatement_privateNotIsDeclVariable() { } @Test - // validForStatement_instanceStaticVariable tests assigning an instance variable with public scope + // validForStatement_instanceStaticVariable tests assigning an instance variable with scope // and static modifier. - public void validForStatement_instanceStaticVariable() { + void validForStatement_instanceStaticVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -113,7 +113,7 @@ public void validForStatement_instanceStaticVariable() { @Test // invalidForStatement_privateIsDeclVariable tests declaring a non-local variable inside of // for-loop. - public void invalidForStatement_privateIsDeclVariable() { + void invalidForStatement_privateIsDeclVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -136,7 +136,7 @@ public void invalidForStatement_privateIsDeclVariable() { @Test // invalidForStatement_staticIsDeclVariable tests declare a static local variable in // initialization expr. - public void invalidForStatement_staticIsDeclVariable() { + void invalidForStatement_staticIsDeclVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).setIsStatic(true).build(); @@ -155,7 +155,7 @@ public void invalidForStatement_staticIsDeclVariable() { @Test // invalidForStatement_finalIsNotDeclVariable tests invalid case of assigning the initial value to // a variable which is declared as a final instance variable. - public void invalidForStatement_finalIsNotDeclVariable() { + void invalidForStatement_finalIsNotDeclVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -179,7 +179,7 @@ public void invalidForStatement_finalIsNotDeclVariable() { @Test // invalidForStatement_localFinalVariable tests declare a final variable in initialization expr, // updateExpr should throw error. - public void invalidForStatement_localFinalVariable() { + void invalidForStatement_localFinalVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).setIsFinal(true).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IdentifierNodeTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IdentifierNodeTest.java index ead7d8be37..d0df3bd62f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IdentifierNodeTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IdentifierNodeTest.java @@ -18,11 +18,11 @@ import static org.junit.Assert.assertThrows; import com.google.api.generator.engine.ast.IdentifierNode.InvalidIdentifierException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class IdentifierNodeTest { +class IdentifierNodeTest { @Test - public void createIdentifier_basic() { + void createIdentifier_basic() { assertValidIdentifier("foobar"); assertValidIdentifier("x"); assertValidIdentifier("afalse"); @@ -34,7 +34,7 @@ public void createIdentifier_basic() { } @Test - public void createIdentifier_nameHasLiteral() { + void createIdentifier_nameHasLiteral() { assertValidIdentifier("a123L"); assertValidIdentifier("a10e3"); assertValidIdentifier("anull"); @@ -51,7 +51,7 @@ public void createIdentifier_nameHasLiteral() { } @Test - public void createIdentifier_namdHasInvalidSymbols() { + void createIdentifier_namdHasInvalidSymbols() { assertInvalidIdentifier("a.b"); assertInvalidIdentifier("a,b"); assertInvalidIdentifier("a-b"); @@ -81,7 +81,7 @@ public void createIdentifier_namdHasInvalidSymbols() { } @Test - public void createIdentifier_nameHasKeyword() { + void createIdentifier_nameHasKeyword() { assertValidIdentifier("aclass"); // Random sampling of keywords. diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IfStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IfStatementTest.java index 46e183d6e0..ab2f8c5674 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IfStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/IfStatementTest.java @@ -18,11 +18,11 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class IfStatementTest { +class IfStatementTest { @Test - public void validIfStatement_simple() { + void validIfStatement_simple() { IfStatement ifStatement = IfStatement.builder() .setConditionExpr(createConditionExpr("condition")) @@ -32,7 +32,7 @@ public void validIfStatement_simple() { } @Test - public void validIfStatement_booleanObjectCondition() { + void validIfStatement_booleanObjectCondition() { // The condition expression type can be boolean or its boxed type. VariableExpr condExpr = VariableExpr.withVariable( @@ -47,7 +47,7 @@ public void validIfStatement_booleanObjectCondition() { } @Test - public void validIfStatement_elseIfsAndElse() { + void validIfStatement_elseIfsAndElse() { VariableExpr condExpr = createConditionExpr("condition"); VariableExpr secondCondExpr = createConditionExpr("secondCondExpr"); VariableExpr thirdCondExpr = createConditionExpr("thirdCondExpr"); @@ -64,7 +64,7 @@ public void validIfStatement_elseIfsAndElse() { } @Test - public void validIfStatement_nested() { + void validIfStatement_nested() { VariableExpr condExpr = createConditionExpr("condition"); VariableExpr nestedCondExpr = createConditionExpr("nestedCondition"); IfStatement nestedIfStatement = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/InstanceofExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/InstanceofExprTest.java index ba53349f85..382c0ebb8c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/InstanceofExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/InstanceofExprTest.java @@ -17,11 +17,11 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class InstanceofExprTest { +class InstanceofExprTest { @Test - public void validInstanceofExpr_basicExprPrimitiveType() { + void validInstanceofExpr_basicExprPrimitiveType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); InstanceofExpr expr = @@ -32,7 +32,7 @@ public void validInstanceofExpr_basicExprPrimitiveType() { } @Test - public void validInstanceofExpr_basicExprObjectType() { + void validInstanceofExpr_basicExprObjectType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); InstanceofExpr.builder().setCheckType(TypeNode.STRING).setExpr(variableExpr).build(); @@ -40,7 +40,7 @@ public void validInstanceofExpr_basicExprObjectType() { } @Test - public void invalidInstanceofExpr_primitiveObjectType() { + void invalidInstanceofExpr_primitiveObjectType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThrows( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/JavaDocCommentTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/JavaDocCommentTest.java index 9c89e3ee44..2d39575e81 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/JavaDocCommentTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/JavaDocCommentTest.java @@ -19,11 +19,11 @@ import com.google.api.generator.test.utils.LineFormatter; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaDocCommentTest { +class JavaDocCommentTest { @Test - public void emptyJavaDocComment() { + void emptyJavaDocComment() { JavaDocComment.Builder javaDocCommentBuilder = JavaDocComment.builder(); assertEquals(true, javaDocCommentBuilder.emptyComments()); @@ -33,14 +33,14 @@ public void emptyJavaDocComment() { } @Test - public void createJavaDocComment_basic() { + void createJavaDocComment_basic() { String content = "this is a test comment"; JavaDocComment javaDocComment = JavaDocComment.builder().addComment(content).build(); assertEquals(content, javaDocComment.comment()); } @Test - public void createJavaDocComment_specialCharacter() { + void createJavaDocComment_specialCharacter() { // Check that we handle special characters correctly which includes escape characters, // html escape characters and unexpected block end `*/`. JavaDocComment javaDocComment = @@ -67,7 +67,7 @@ public void createJavaDocComment_specialCharacter() { } @Test - public void createJavaDocComment_sampleCode() { + void createJavaDocComment_sampleCode() { String comment = "sample codes:"; String sampleCode = "resource = project/{project}/shelfId/{shelfId}"; JavaDocComment javaDocComment = @@ -82,7 +82,7 @@ public void createJavaDocComment_sampleCode() { } @Test - public void createJavaDocComment_sampleCodePreserveIndentAndLineBreaks() { + void createJavaDocComment_sampleCodePreserveIndentAndLineBreaks() { String comment = "sample codes:"; String formattedSampleCode = LineFormatter.lines( @@ -107,7 +107,7 @@ public void createJavaDocComment_sampleCodePreserveIndentAndLineBreaks() { } @Test - public void createJavaDocComment_multipleComments() { + void createJavaDocComment_multipleComments() { // Add methods, like `addComment()`, should add components at any place, // and they will get printed in order. String comment1 = "This is a test comment."; @@ -142,7 +142,7 @@ public void createJavaDocComment_multipleComments() { } @Test - public void createJavaDocComment_multipleParams() { + void createJavaDocComment_multipleParams() { // Parameters should be grouped together and get printed after block comments. String comment = "This is a block comment."; String paramName1 = "shelfName"; @@ -163,7 +163,7 @@ public void createJavaDocComment_multipleParams() { } @Test - public void createJavaDocComment_multipleParamsAndReturn() { + void createJavaDocComment_multipleParamsAndReturn() { // Parameters should be grouped together and get printed after block comments. // Return text should get printed at the very end. String comment = "This is a block comment."; @@ -188,7 +188,7 @@ public void createJavaDocComment_multipleParamsAndReturn() { } @Test - public void createJavaDocComment_throwsAndDeprecatedAndReturn() { + void createJavaDocComment_throwsAndDeprecatedAndReturn() { // No matter how many times or order `setThrows`, `setDeprecated`, `setReturn` are called, // only one @throws, @deprecated, and @return will be printed. String throwsType = "com.google.api.gax.rpc.ApiException"; @@ -220,7 +220,7 @@ public void createJavaDocComment_throwsAndDeprecatedAndReturn() { } @Test - public void createJavaDocComment_allComponents() { + void createJavaDocComment_allComponents() { // No matter what order `setThrows`, `setDeprecated`, and `setReturn` are called, // They will be printed at the end. And `@param` should be grouped, // they should always be printed right before `@throws`, `@deprecated`, and `@return`. diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LambdaExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LambdaExprTest.java index 46bca0357f..15e35858b0 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LambdaExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LambdaExprTest.java @@ -18,18 +18,18 @@ import static org.junit.Assert.assertThrows; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class LambdaExprTest { +class LambdaExprTest { @Test - public void validLambdaExpr_noArguments() { + void validLambdaExpr_noArguments() { LambdaExpr.builder() .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue("foo"))) .build(); } @Test - public void validLambdaExpr_inferTypeFromReturnExpr() { + void validLambdaExpr_inferTypeFromReturnExpr() { LambdaExpr lambdaExpr = LambdaExpr.builder() .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue("foo"))) @@ -38,7 +38,7 @@ public void validLambdaExpr_inferTypeFromReturnExpr() { } @Test - public void validLambdaExpr_severalArguments() { + void validLambdaExpr_severalArguments() { VariableExpr argOneVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -62,7 +62,7 @@ public void validLambdaExpr_severalArguments() { } @Test - public void validLambdaExpr_withBody() { + void validLambdaExpr_withBody() { VariableExpr fooVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("foo").setType(TypeNode.INT).build()) @@ -85,7 +85,7 @@ public void validLambdaExpr_withBody() { } @Test - public void validLambdaExpr_returnsVoid() { + void validLambdaExpr_returnsVoid() { LambdaExpr voidLambda = LambdaExpr.builder() .setReturnExpr( @@ -98,7 +98,7 @@ public void validLambdaExpr_returnsVoid() { } @Test - public void invalidLambdaExpr_undeclaredArgVarExpr() { + void invalidLambdaExpr_undeclaredArgVarExpr() { VariableExpr argVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -114,7 +114,7 @@ public void invalidLambdaExpr_undeclaredArgVarExpr() { } @Test - public void invalidLambdaExpr_argVarExprWithModifiers() { + void invalidLambdaExpr_argVarExprWithModifiers() { VariableExpr argVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -132,7 +132,7 @@ public void invalidLambdaExpr_argVarExprWithModifiers() { } @Test - public void invalidLambdaExpr_argVarExprWithNonLocalScope() { + void invalidLambdaExpr_argVarExprWithNonLocalScope() { VariableExpr argVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -150,7 +150,7 @@ public void invalidLambdaExpr_argVarExprWithNonLocalScope() { } @Test - public void invalidLambdaExpr_repeatedArgName() { + void invalidLambdaExpr_repeatedArgName() { VariableExpr argOneVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LogicalOperationExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LogicalOperationExprTest.java index 3a54cb2706..df39b03121 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LogicalOperationExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/LogicalOperationExprTest.java @@ -16,12 +16,12 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class LogicalOperationExprTest { +class LogicalOperationExprTest { /** =============================== Logic And Operation Expr =============================== */ @Test - public void logicalAnd_validBasic() { + void logicalAnd_validBasic() { VariableExpr lhsExpr = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN).setName("isGood").build()); @@ -33,7 +33,7 @@ public void logicalAnd_validBasic() { } @Test - public void logicalAnd_validBoxedBoolean() { + void logicalAnd_validBoxedBoolean() { VariableExpr lhsExpr = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN).setName("isGood").build()); @@ -45,7 +45,7 @@ public void logicalAnd_validBoxedBoolean() { } @Test - public void logicalAnd_invalidNumericType() { + void logicalAnd_invalidNumericType() { VariableExpr lhsExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.INT).setName("x").build()); VariableExpr rhsExpr = @@ -57,7 +57,7 @@ public void logicalAnd_invalidNumericType() { } @Test - public void logicalAnd_invalidStringType() { + void logicalAnd_invalidStringType() { VariableExpr lhsExpr = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN_OBJECT).setName("x").build()); @@ -71,7 +71,7 @@ public void logicalAnd_invalidStringType() { /** =============================== Logic Or Operation Expr =============================== */ @Test - public void logicalOr_validBoxedBoolean() { + void logicalOr_validBoxedBoolean() { VariableExpr lhsExpr = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN_OBJECT).setName("isGood").build()); @@ -83,7 +83,7 @@ public void logicalOr_validBoxedBoolean() { } @Test - public void logicalOr_invalidVoidType() { + void logicalOr_invalidVoidType() { VariableExpr lhsExpr = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN).setName("x").build()); @@ -95,7 +95,7 @@ public void logicalOr_invalidVoidType() { } @Test - public void logicalOr_invalidNullType() { + void logicalOr_invalidNullType() { VariableExpr lhsExpr = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN).setName("x").build()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodDefinitionTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodDefinitionTest.java index 96e09352cc..17db2d8019 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodDefinitionTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodDefinitionTest.java @@ -21,11 +21,11 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MethodDefinitionTest { +class MethodDefinitionTest { @Test - public void validMethodDefinition_basicWithComments() { + void validMethodDefinition_basicWithComments() { MethodDefinition.builder() .setHeaderCommentStatements(createCommentStatements()) .setName("close") @@ -37,7 +37,7 @@ public void validMethodDefinition_basicWithComments() { } @Test - public void validMethodDefinition_emptyBody() { + void validMethodDefinition_emptyBody() { MethodDefinition.builder() .setHeaderCommentStatements(createCommentStatements()) .setName("close") @@ -47,7 +47,7 @@ public void validMethodDefinition_emptyBody() { } @Test - public void validMethodDefinition_repeatedAnnotations() { + void validMethodDefinition_repeatedAnnotations() { MethodDefinition method = MethodDefinition.builder() .setName("close") @@ -65,7 +65,7 @@ public void validMethodDefinition_repeatedAnnotations() { } @Test - public void validMethodDefinition_basicWithReturnType() { + void validMethodDefinition_basicWithReturnType() { MethodDefinition.builder() .setName("close") .setScope(ScopeNode.PUBLIC) @@ -81,7 +81,7 @@ public void validMethodDefinition_basicWithReturnType() { } @Test - public void validMethodDefinition_throwInsteadOfReturnType() { + void validMethodDefinition_throwInsteadOfReturnType() { MethodDefinition.builder() .setName("foobar") .setScope(ScopeNode.PUBLIC) @@ -99,7 +99,7 @@ public void validMethodDefinition_throwInsteadOfReturnType() { } @Test - public void validMethodDefinition_voidThrowInsteadOfReturnType() { + void validMethodDefinition_voidThrowInsteadOfReturnType() { MethodDefinition.builder() .setName("foobar") .setScope(ScopeNode.PUBLIC) @@ -117,7 +117,7 @@ public void validMethodDefinition_voidThrowInsteadOfReturnType() { } @Test - public void validMethodDefinition_subtyping() { + void validMethodDefinition_subtyping() { Reference stringRef = ConcreteReference.withClazz(String.class); TypeNode returnType = TypeNode.withReference( @@ -149,7 +149,7 @@ public void validMethodDefinition_subtyping() { } @Test - public void validMethodDefinition_basicAbstract() { + void validMethodDefinition_basicAbstract() { MethodDefinition.builder() .setName("close") .setIsAbstract(true) @@ -160,7 +160,7 @@ public void validMethodDefinition_basicAbstract() { } @Test - public void validMethodDefinition_constructor() { + void validMethodDefinition_constructor() { TypeNode returnType = TypeNode.withReference( VaporReference.builder() @@ -174,7 +174,7 @@ public void validMethodDefinition_constructor() { } @Test - public void validMethodDefinition_withArgumentsAndReturnExpr() { + void validMethodDefinition_withArgumentsAndReturnExpr() { ValueExpr returnExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build()) @@ -201,7 +201,7 @@ public void validMethodDefinition_withArgumentsAndReturnExpr() { } @Test - public void validMethodDefinition_nonRuntimeException() { + void validMethodDefinition_nonRuntimeException() { MethodDefinition.builder() .setName("close") .setScope(ScopeNode.PUBLIC) @@ -213,7 +213,7 @@ public void validMethodDefinition_nonRuntimeException() { } @Test - public void validMethodDefinition_templateBasic() { + void validMethodDefinition_templateBasic() { TypeNode returnType = TypeNode.withReference(ConcreteReference.withClazz(Map.class)); MethodDefinition.builder() .setName("close") @@ -231,7 +231,7 @@ public void validMethodDefinition_templateBasic() { } @Test - public void validMethodDefinition_templateOnArguments() { + void validMethodDefinition_templateOnArguments() { Reference listRef = ConcreteReference.withClazz(List.class); List arguments = Arrays.asList( @@ -263,7 +263,7 @@ public void validMethodDefinition_templateOnArguments() { } @Test - public void validMethodDefinition_primitiveReturnTypeWithoutTemplates() { + void validMethodDefinition_primitiveReturnTypeWithoutTemplates() { // Not valid Java. Please change this test if you are trying to prevent this case. MethodDefinition.builder() .setName("close") @@ -275,7 +275,7 @@ public void validMethodDefinition_primitiveReturnTypeWithoutTemplates() { } @Test - public void validMethodDefinition_boxedReturnType() { + void validMethodDefinition_boxedReturnType() { MethodDefinition.builder() .setName("foobar") .setScope(ScopeNode.PUBLIC) @@ -288,7 +288,7 @@ public void validMethodDefinition_boxedReturnType() { } @Test - public void validMethodDefinition_setReturnExprUsingReturnExpr() { + void validMethodDefinition_setReturnExprUsingReturnExpr() { ReturnExpr returnExpr = ReturnExpr.withExpr( ValueExpr.withValue( @@ -303,7 +303,7 @@ public void validMethodDefinition_setReturnExprUsingReturnExpr() { } @Test - public void invalidMethodDefinition_badTemplateName() { + void invalidMethodDefinition_badTemplateName() { assertThrows( IdentifierNode.InvalidIdentifierException.class, () -> @@ -317,7 +317,7 @@ public void invalidMethodDefinition_badTemplateName() { } @Test - public void invalidMethodDefinition_primitiveReturnType() { + void invalidMethodDefinition_primitiveReturnType() { assertThrows( IllegalStateException.class, () -> @@ -332,7 +332,7 @@ public void invalidMethodDefinition_primitiveReturnType() { } @Test - public void invalidMethodDefinition_emptyTemplatesOnMethod() { + void invalidMethodDefinition_emptyTemplatesOnMethod() { assertThrows( IllegalStateException.class, () -> @@ -348,7 +348,7 @@ public void invalidMethodDefinition_emptyTemplatesOnMethod() { } @Test - public void invalidMethodDefinition_returnTemplatesNotPresent() { + void invalidMethodDefinition_returnTemplatesNotPresent() { assertThrows( IllegalStateException.class, () -> @@ -365,7 +365,7 @@ public void invalidMethodDefinition_returnTemplatesNotPresent() { } @Test - public void invalidMethodDefinition_noName() { + void invalidMethodDefinition_noName() { assertThrows( NullPointerException.class, () -> { @@ -378,7 +378,7 @@ public void invalidMethodDefinition_noName() { } @Test - public void invalidMethodDefinition_runtimeException() { + void invalidMethodDefinition_runtimeException() { assertThrows( IllegalStateException.class, () -> { @@ -394,7 +394,7 @@ public void invalidMethodDefinition_runtimeException() { } @Test - public void invalidMethodDefinition_abstractStatic() { + void invalidMethodDefinition_abstractStatic() { assertThrows( IllegalStateException.class, () -> { @@ -409,7 +409,7 @@ public void invalidMethodDefinition_abstractStatic() { } @Test - public void invalidMethodDefinition_localScope() { + void invalidMethodDefinition_localScope() { assertThrows( IllegalStateException.class, () -> { @@ -422,7 +422,7 @@ public void invalidMethodDefinition_localScope() { } @Test - public void invalidMethodDefinition_constructorOverride() { + void invalidMethodDefinition_constructorOverride() { TypeNode returnType = TypeNode.withReference( VaporReference.builder() @@ -441,7 +441,7 @@ public void invalidMethodDefinition_constructorOverride() { } @Test - public void invalidMethodDefinition_constructorFinalOrStatic() { + void invalidMethodDefinition_constructorFinalOrStatic() { TypeNode returnType = TypeNode.withReference( VaporReference.builder() @@ -469,7 +469,7 @@ public void invalidMethodDefinition_constructorFinalOrStatic() { } @Test - public void invalidMethodDefinition_constructorHasReturnExpr() { + void invalidMethodDefinition_constructorHasReturnExpr() { TypeNode returnType = TypeNode.withReference( VaporReference.builder() @@ -492,7 +492,7 @@ public void invalidMethodDefinition_constructorHasReturnExpr() { } @Test - public void invalidMethodDefinition_objectPrimitiveTypeMismatch() { + void invalidMethodDefinition_objectPrimitiveTypeMismatch() { Value value = PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build(); ValueExpr valueExpr = ValueExpr.builder().setValue(value).build(); @@ -510,7 +510,7 @@ public void invalidMethodDefinition_objectPrimitiveTypeMismatch() { } @Test - public void invalidMethodDefinition_mismatchedTypes() { + void invalidMethodDefinition_mismatchedTypes() { Reference stringRef = ConcreteReference.withClazz(String.class); TypeNode returnType = TypeNode.withReference( @@ -539,7 +539,7 @@ public void invalidMethodDefinition_mismatchedTypes() { } @Test - public void invalidMethodDefinition_abstractFinal() { + void invalidMethodDefinition_abstractFinal() { assertThrows( IllegalStateException.class, () -> { @@ -554,7 +554,7 @@ public void invalidMethodDefinition_abstractFinal() { } @Test - public void invalidMethodDefinition_abstractPrivate() { + void invalidMethodDefinition_abstractPrivate() { assertThrows( IllegalStateException.class, () -> { @@ -568,7 +568,7 @@ public void invalidMethodDefinition_abstractPrivate() { } @Test - public void invalidMethodDefinition_invalidException() { + void invalidMethodDefinition_invalidException() { assertThrows( IllegalStateException.class, () -> { @@ -583,7 +583,7 @@ public void invalidMethodDefinition_invalidException() { } @Test - public void invalidMethodDefinition_missingNonVoidReturnType() { + void invalidMethodDefinition_missingNonVoidReturnType() { assertThrows( NullPointerException.class, () -> { @@ -597,7 +597,7 @@ public void invalidMethodDefinition_missingNonVoidReturnType() { } @Test - public void invalidMethodDefinition_mismatchedPrimitiveReturnType() { + void invalidMethodDefinition_mismatchedPrimitiveReturnType() { ValueExpr booleanValueExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("false").build()) @@ -616,7 +616,7 @@ public void invalidMethodDefinition_mismatchedPrimitiveReturnType() { } @Test - public void invalidMethodDefinition_mismatchedObjectReturnType() { + void invalidMethodDefinition_mismatchedObjectReturnType() { assertThrows( IllegalStateException.class, () -> { @@ -635,7 +635,7 @@ public void invalidMethodDefinition_mismatchedObjectReturnType() { } @Test - public void invalidMethodDefinition_mismatchedPrimitiveToObjectReturnType() { + void invalidMethodDefinition_mismatchedPrimitiveToObjectReturnType() { assertThrows( IllegalStateException.class, () -> { @@ -654,7 +654,7 @@ public void invalidMethodDefinition_mismatchedPrimitiveToObjectReturnType() { } @Test - public void invalidMethodDefinition_repeatedArgumentName() { + void invalidMethodDefinition_repeatedArgumentName() { ValueExpr returnValueExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build()) @@ -678,7 +678,7 @@ public void invalidMethodDefinition_repeatedArgumentName() { } @Test - public void invalidMethodDefinition_nonDeclArguments() { + void invalidMethodDefinition_nonDeclArguments() { ValueExpr returnValueExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build()) @@ -702,7 +702,7 @@ public void invalidMethodDefinition_nonDeclArguments() { } @Test - public void invalidMethodDefinition_argumentsWithModifiers() { + void invalidMethodDefinition_argumentsWithModifiers() { ValueExpr returnValueExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build()) @@ -729,7 +729,7 @@ public void invalidMethodDefinition_argumentsWithModifiers() { } @Test - public void invalidMethodDefinition_argumentsWithScope() { + void invalidMethodDefinition_argumentsWithScope() { ValueExpr returnValueExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build()) @@ -755,7 +755,7 @@ public void invalidMethodDefinition_argumentsWithScope() { } @Test - public void invalidMethodDefinition_nullReturnType() { + void invalidMethodDefinition_nullReturnType() { assertThrows( IllegalStateException.class, () -> { @@ -768,7 +768,7 @@ public void invalidMethodDefinition_nullReturnType() { } @Test - public void invalidMethodDefinition_missingReturnType() { + void invalidMethodDefinition_missingReturnType() { assertThrows( NullPointerException.class, () -> { diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodInvocationExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodInvocationExprTest.java index eed99da9b7..7261cd2b77 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodInvocationExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/MethodInvocationExprTest.java @@ -18,12 +18,12 @@ import java.util.ArrayList; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MethodInvocationExprTest { +class MethodInvocationExprTest { @Test - public void validBuildMethodInvocationExpr() { + void validBuildMethodInvocationExpr() { Reference stringRef = ConcreteReference.withClazz(String.class); TypeNode returnType = TypeNode.withReference( @@ -37,7 +37,7 @@ public void validBuildMethodInvocationExpr() { } @Test - public void validBuildMethodInvocationExpr_hasArguments() { + void validBuildMethodInvocationExpr_hasArguments() { Reference stringRef = ConcreteReference.withClazz(String.class); TypeNode returnType = TypeNode.withReference( @@ -59,7 +59,7 @@ public void validBuildMethodInvocationExpr_hasArguments() { } @Test - public void validBuildMethodInvocationExpr_staticReference() { + void validBuildMethodInvocationExpr_staticReference() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -75,7 +75,7 @@ public void validBuildMethodInvocationExpr_staticReference() { } @Test - public void invalidBuildMethodInvocationExpr_nullReturnType() { + void invalidBuildMethodInvocationExpr_nullReturnType() { assertThrows( IllegalStateException.class, () -> { @@ -87,7 +87,7 @@ public void invalidBuildMethodInvocationExpr_nullReturnType() { } @Test - public void invalidBuildMethodInvocationExpr_staticAndExprBoth() { + void invalidBuildMethodInvocationExpr_staticAndExprBoth() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -110,7 +110,7 @@ public void invalidBuildMethodInvocationExpr_staticAndExprBoth() { } @Test - public void invalidBuildMethodInvocationExpr_nullArgument() { + void invalidBuildMethodInvocationExpr_nullArgument() { Reference stringRef = ConcreteReference.withClazz(String.class); TypeNode returnType = TypeNode.withReference( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NewObjectExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NewObjectExprTest.java index 2287a75394..12112f7b45 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NewObjectExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NewObjectExprTest.java @@ -21,11 +21,11 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class NewObjectExprTest { +class NewObjectExprTest { @Test - public void validNewObjectValue_basic() { + void validNewObjectValue_basic() { // isGeneric() is true and generics() is not empty. // [Constructing] `new List()`, no exception should be thrown. ConcreteReference ref = @@ -40,7 +40,7 @@ public void validNewObjectValue_basic() { } @Test - public void validNewObjectValue_hasArgument() { + void validNewObjectValue_hasArgument() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -58,7 +58,7 @@ public void validNewObjectValue_hasArgument() { } @Test - public void validNewObjectExpr_edgeCase() { + void validNewObjectExpr_edgeCase() { // isGeneric() is false, but generics() is not empty. // The expression is still valid, we will set isGeneric() as true for the users. // [Constructing] `new List()`, no exception should be thrown. @@ -74,7 +74,7 @@ public void validNewObjectExpr_edgeCase() { } @Test - public void validNewObjectExpr_noGenericWithArgs() { + void validNewObjectExpr_noGenericWithArgs() { // isGeneric() is false, and generics() is empty. // [Constructing] `new Integer(123)` no exception should be thrown. ConcreteReference ref = ConcreteReference.builder().setClazz(Integer.class).build(); @@ -88,7 +88,7 @@ public void validNewObjectExpr_noGenericWithArgs() { } @Test - public void validNewObjectExpr_emptyGeneric() { + void validNewObjectExpr_emptyGeneric() { // isGeneric() is true, but generics() is empty. // [Constructing] `new LinkedList<>()` no exception should be thrown. ConcreteReference ref = ConcreteReference.builder().setClazz(LinkedList.class).build(); @@ -99,7 +99,7 @@ public void validNewObjectExpr_emptyGeneric() { } @Test - public void validNewObjectExpr_genericsAndArgs() { + void validNewObjectExpr_genericsAndArgs() { // isGeneric() is true, generics() is not empty, and argument list is also not empty. // [Constructing] `new HashMap, Integer>>(initialCapacity, loadFactor)`. ConcreteReference listRef = @@ -130,7 +130,7 @@ public void validNewObjectExpr_genericsAndArgs() { } @Test - public void invalidNewObjectExpr_primitiveType() { + void invalidNewObjectExpr_primitiveType() { // New object expressions should be reference types. assertThrows( IllegalStateException.class, @@ -140,7 +140,7 @@ public void invalidNewObjectExpr_primitiveType() { } @Test - public void invalidNewObjectExpr_nullType() { + void invalidNewObjectExpr_nullType() { // New object expressions cannot be null type. assertThrows( IllegalStateException.class, @@ -150,7 +150,7 @@ public void invalidNewObjectExpr_nullType() { } @Test - public void invalidNewObjectValue_nullArgument() { + void invalidNewObjectValue_nullArgument() { VaporReference ref = VaporReference.builder() .setName("Student") diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NullObjectValueTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NullObjectValueTest.java index fa9dfa2669..8e31801a47 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NullObjectValueTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/NullObjectValueTest.java @@ -17,13 +17,13 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class NullObjectValueTest { +class NullObjectValueTest { private static final String NULL_VALUE = "null"; @Test - public void createNullObjectValue_valid() { + void createNullObjectValue_valid() { NullObjectValue nullValue = NullObjectValue.create(); assertEquals(NULL_VALUE, nullValue.value()); assertThat(nullValue.type()).isEqualTo(TypeNode.NULL); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/PrimitiveValueTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/PrimitiveValueTest.java index 37c3ae9cc4..6045d7ec35 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/PrimitiveValueTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/PrimitiveValueTest.java @@ -19,11 +19,11 @@ import static org.junit.Assert.assertThrows; import com.google.api.generator.engine.ast.TypeNode.TypeKind; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PrimitiveValueTest { +class PrimitiveValueTest { @Test - public void createPrimitiveValue_basic() { + void createPrimitiveValue_basic() { assertValidValue(TypeKind.INT, "3"); assertValidValue(TypeKind.BOOLEAN, "false"); assertValidValue(TypeKind.LONG, "123"); @@ -32,7 +32,7 @@ public void createPrimitiveValue_basic() { } @Test - public void createPrimitiveValue_invalid() { + void createPrimitiveValue_invalid() { assertInvalidValue(TypeKind.INT, "123.f"); assertInvalidValue(TypeKind.INT, "false"); assertInvalidValue(TypeKind.BOOLEAN, "False"); @@ -40,7 +40,7 @@ public void createPrimitiveValue_invalid() { } @Test - public void createPrimitiveValue_unsupported() { + void createPrimitiveValue_unsupported() { assertInvalidValue(TypeKind.BYTE, "0x2"); assertInvalidValue(TypeKind.SHORT, "1"); assertInvalidValue(TypeKind.CHAR, "a"); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceConstructorExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceConstructorExprTest.java index 8ba47c8ac6..03e579d411 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceConstructorExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceConstructorExprTest.java @@ -16,12 +16,12 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ReferenceConstructorExprTest { +class ReferenceConstructorExprTest { @Test - public void validReferenceConstructorExpr_thisConstructorBasic() { + void validReferenceConstructorExpr_thisConstructorBasic() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -33,7 +33,7 @@ public void validReferenceConstructorExpr_thisConstructorBasic() { } @Test - public void validReferenceConstructorExpr_hasArguments() { + void validReferenceConstructorExpr_hasArguments() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -51,7 +51,7 @@ public void validReferenceConstructorExpr_hasArguments() { } @Test - public void validReferenceConstructorExpr_superConstructorBasic() { + void validReferenceConstructorExpr_superConstructorBasic() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -63,7 +63,7 @@ public void validReferenceConstructorExpr_superConstructorBasic() { } @Test - public void invalidReferenceConstructorExpr_nonReferenceType() { + void invalidReferenceConstructorExpr_nonReferenceType() { assertThrows( IllegalStateException.class, () -> { @@ -72,7 +72,7 @@ public void invalidReferenceConstructorExpr_nonReferenceType() { } @Test - public void invalidReferenceConstructorExpr_nullType() { + void invalidReferenceConstructorExpr_nullType() { assertThrows( IllegalStateException.class, () -> { @@ -81,7 +81,7 @@ public void invalidReferenceConstructorExpr_nullType() { } @Test - public void invalidReferenceConstructorExpr_nullArgument() { + void invalidReferenceConstructorExpr_nullArgument() { VaporReference ref = VaporReference.builder() .setName("Student") diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceTest.java index b4e4b43496..c210900a4f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReferenceTest.java @@ -20,11 +20,11 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ReferenceTest { +class ReferenceTest { @Test - public void nestedGenerics_concreteReferenceOuter() { + void nestedGenerics_concreteReferenceOuter() { Reference mapReference = VaporReference.builder() .setName("HashMap") @@ -50,7 +50,7 @@ public void nestedGenerics_concreteReferenceOuter() { } @Test - public void nestedGenerics_vaporReferenceOuter() { + void nestedGenerics_vaporReferenceOuter() { Reference mapReference = ConcreteReference.builder() .setClazz(HashMap.class) @@ -77,7 +77,7 @@ public void nestedGenerics_vaporReferenceOuter() { } @Test - public void mixedConcreteVaporReferenceEquals() { + void mixedConcreteVaporReferenceEquals() { Reference mapReferenceVaporOuter = ConcreteReference.builder() .setClazz(HashMap.class) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/RelationalOperationExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/RelationalOperationExprTest.java index f1b3f1f424..829f763328 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/RelationalOperationExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/RelationalOperationExprTest.java @@ -17,12 +17,12 @@ import static org.junit.Assert.assertThrows; import com.google.api.generator.engine.ast.TypeNode.TypeKind; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class RelationalOperationExprTest { +class RelationalOperationExprTest { /** ==================== Equality Operators: LHS data type is numeric ======================= */ @Test - public void equalToOperationExpr_validBasic() { + void equalToOperationExpr_validBasic() { // LHS: numeric type, RHS: matched numeric type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); @@ -32,7 +32,7 @@ public void equalToOperationExpr_validBasic() { } @Test - public void equalToOperationExpr_validNumericTYpe() { + void equalToOperationExpr_validNumericTYpe() { // LHS: numeric type, RHS: unmatched numeric type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR, "x"); @@ -42,7 +42,7 @@ public void equalToOperationExpr_validNumericTYpe() { } @Test - public void notEqualToOperationExpr_validMatchedNumericBoxTYpe() { + void notEqualToOperationExpr_validMatchedNumericBoxTYpe() { // LHS: numeric type, RHS: matched numeric Boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validBoxedWithMatchedUnBoxedType". @@ -53,7 +53,7 @@ public void notEqualToOperationExpr_validMatchedNumericBoxTYpe() { } @Test - public void notEqualToOperationExpr_validNumericBoxTYpe() { + void notEqualToOperationExpr_validNumericBoxTYpe() { // LHS: numeric type, RHS: unmatched numeric Boxed type. // Swapping LHS and RHS test case is covered in // equalToOperationExpr_validBoxedWithUnmatchedUnBoxedType". @@ -64,7 +64,7 @@ public void notEqualToOperationExpr_validNumericBoxTYpe() { } @Test - public void equalToOperationExpr_invalidNumericBooleanBoxedType() { + void equalToOperationExpr_invalidNumericBooleanBoxedType() { // LHS: numeric type, RHS: boolean boxed Type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidBoxedBooleanWithNumericType". @@ -76,7 +76,7 @@ public void equalToOperationExpr_invalidNumericBooleanBoxedType() { } @Test - public void notEqualToOperationExpr_invalidNumericStringType() { + void notEqualToOperationExpr_invalidNumericStringType() { // LHS: numeric type, RHS: referenced type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidReferenceWithNumericType". @@ -88,7 +88,7 @@ public void notEqualToOperationExpr_invalidNumericStringType() { } @Test - public void notEqualToOperationExpr_invalidNumericNullType() { + void notEqualToOperationExpr_invalidNumericNullType() { // LHS: numeric type, RHS: null. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNullWithNumericType". @@ -100,7 +100,7 @@ public void notEqualToOperationExpr_invalidNumericNullType() { } @Test - public void equalToOperationExpr_invalidNumericBooleanType() { + void equalToOperationExpr_invalidNumericBooleanType() { // LHS: numeric type, RHS: boolean boxed Type. // Swapping LHS and RHS test case is covered in // notEqualToOperationExpr_invalidBooleanToNumericType. @@ -112,7 +112,7 @@ public void equalToOperationExpr_invalidNumericBooleanType() { } @Test - public void equalToOperationExpr_invalidNumericTypeWithArrayType() { + void equalToOperationExpr_invalidNumericTypeWithArrayType() { // LHS: Numeric Type, RHS: Array with numeric type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidArrayWithNotArrayType". @@ -127,7 +127,7 @@ public void equalToOperationExpr_invalidNumericTypeWithArrayType() { /** =============== Equality Operators: LHS data type is numeric boxed type ================ */ @Test - public void equalToOperationExpr_validBoxedWithMatchedBoxedType() { + void equalToOperationExpr_validBoxedWithMatchedBoxedType() { // LHS: Boxed type, RHS: Matched Boxed. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -137,7 +137,7 @@ public void equalToOperationExpr_validBoxedWithMatchedBoxedType() { } @Test - public void equalToOperationExpr_validBoxedWithMatchedUnBoxedType() { + void equalToOperationExpr_validBoxedWithMatchedUnBoxedType() { // LHS: Boxed type, RHS: Unmatched Boxed. // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_validMatchedNumericBoxTYpe". @@ -148,7 +148,7 @@ public void equalToOperationExpr_validBoxedWithMatchedUnBoxedType() { } @Test - public void equalToOperationExpr_validBoxedWithUnmatchedUnBoxedType() { + void equalToOperationExpr_validBoxedWithUnmatchedUnBoxedType() { // LHS: Numeric boxed type, RHS: other numeric type. // Swapping LHS and RHS test case is covered in "notEqualToOperationExpr_validNumericBoxTYpe". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT_OBJECT, "x"); @@ -158,7 +158,7 @@ public void equalToOperationExpr_validBoxedWithUnmatchedUnBoxedType() { } @Test - public void equalToOperationExpr_validNumericBoxedWithNullType() { + void equalToOperationExpr_validNumericBoxedWithNullType() { // LHS: Boxed type, RHS: Null. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNullWithNumericBoxedType". @@ -169,7 +169,7 @@ public void equalToOperationExpr_validNumericBoxedWithNullType() { } @Test - public void equalToOperationExpr_validNumericBoxedWithNewObjectType() { + void equalToOperationExpr_validNumericBoxedWithNewObjectType() { // LHS: Numeric boxed type, RHS: new object. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validObjectWithNumericBoxedType". @@ -180,7 +180,7 @@ public void equalToOperationExpr_validNumericBoxedWithNewObjectType() { } @Test - public void equalToOperationExpr_invalidNumericBoxedWithBooleanType() { + void equalToOperationExpr_invalidNumericBoxedWithBooleanType() { // LHS: Numeric boxed type, RHS: Boolean type. // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_invalidBooleanToOtherBoxedType". @@ -192,7 +192,7 @@ public void equalToOperationExpr_invalidNumericBoxedWithBooleanType() { } @Test - public void equalToOperationExpr_invalidNumericBoxedWithBooleanBoxedType() { + void equalToOperationExpr_invalidNumericBoxedWithBooleanBoxedType() { // LHS: Numeric boxed type, RHS: Boolean Boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidBooleanBoxedWithNumericBoxedType". @@ -204,7 +204,7 @@ public void equalToOperationExpr_invalidNumericBoxedWithBooleanBoxedType() { } @Test - public void equalToOperationExpr_invalidNumericBoxedWithReferenceType() { + void equalToOperationExpr_invalidNumericBoxedWithReferenceType() { // LHS: Numeric boxed type, RHS: Reference type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidReferenceWithNumericBoxedType". @@ -217,7 +217,7 @@ public void equalToOperationExpr_invalidNumericBoxedWithReferenceType() { /** ============= Equality Operators: LHS data type is boolean or its boxed type ============== */ @Test - public void equalToOperationExpr_validBooleanType() { + void equalToOperationExpr_validBooleanType() { // LHS: boolean type, RHS: boolean Type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); @@ -227,7 +227,7 @@ public void equalToOperationExpr_validBooleanType() { } @Test - public void equalToOperationExpr_validRHSBooleanBoxedType() { + void equalToOperationExpr_validRHSBooleanBoxedType() { // LHS: boolean type, RHS: boolean boxed Type. // Swapping LHS and RHS test case is covered in "equalToOperationExpr_validLHSBooleanBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN, "x"); @@ -237,7 +237,7 @@ public void equalToOperationExpr_validRHSBooleanBoxedType() { } @Test - public void equalToOperationExpr_validLHSBooleanBoxedType() { + void equalToOperationExpr_validLHSBooleanBoxedType() { // LHS: boolean boxed type, RHS: boolean Type. // Swapping LHS and RHS test case is covered in "equalToOperationExpr_validRHSBooleanBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.BOOLEAN_OBJECT, "x"); @@ -247,7 +247,7 @@ public void equalToOperationExpr_validLHSBooleanBoxedType() { } @Test - public void notEqualToOperationExpr_validBooleanBoxedToNullType() { + void notEqualToOperationExpr_validBooleanBoxedToNullType() { // LHS: boolean boxed type, RHS: null. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNullWithBooleanBoxedType". @@ -258,7 +258,7 @@ public void notEqualToOperationExpr_validBooleanBoxedToNullType() { } @Test - public void notEqualToOperationExpr_validBooleanBoxedToObjectType() { + void notEqualToOperationExpr_validBooleanBoxedToObjectType() { // LHS: boolean boxed type, RHS: null. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validObjectWithBooleanBoxedType". @@ -269,7 +269,7 @@ public void notEqualToOperationExpr_validBooleanBoxedToObjectType() { } @Test - public void notEqualToOperationExpr_invalidBooleanToNumericType() { + void notEqualToOperationExpr_invalidBooleanToNumericType() { // LHS: boolean type, RHS: char boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNumericBooleanType". @@ -281,7 +281,7 @@ public void notEqualToOperationExpr_invalidBooleanToNumericType() { } @Test - public void notEqualToOperationExpr_invalidBooleanToOtherBoxedType() { + void notEqualToOperationExpr_invalidBooleanToOtherBoxedType() { // LHS: boolean type, RHS: numeric boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNumericBoxedWithBooleanType". @@ -293,7 +293,7 @@ public void notEqualToOperationExpr_invalidBooleanToOtherBoxedType() { } @Test - public void notEqualToOperationExpr_invalidBooleanToReferenceType() { + void notEqualToOperationExpr_invalidBooleanToReferenceType() { // LHS: boolean type, RHS: object type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidReferenceWithBooleanType". @@ -305,7 +305,7 @@ public void notEqualToOperationExpr_invalidBooleanToReferenceType() { } @Test - public void equalToOperationExpr_invalidBooleanWithNullType() { + void equalToOperationExpr_invalidBooleanWithNullType() { // LHS: boolean type, RHS: null type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNullWithBooleanType". @@ -317,7 +317,7 @@ public void equalToOperationExpr_invalidBooleanWithNullType() { } @Test - public void equalToOperationExpr_invalidBooleanWithObjectType() { + void equalToOperationExpr_invalidBooleanWithObjectType() { // LHS: boolean type, RHS: object type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidObjectWithBooleanType". @@ -329,7 +329,7 @@ public void equalToOperationExpr_invalidBooleanWithObjectType() { } @Test - public void equalToOperationExpr_invalidBoxedBooleanWithNumericType() { + void equalToOperationExpr_invalidBoxedBooleanWithNumericType() { // LHS: boolean boxed type, RHS: numeric // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNumericBooleanBoxedType". @@ -341,7 +341,7 @@ public void equalToOperationExpr_invalidBoxedBooleanWithNumericType() { } @Test - public void equalToOperationExpr_invalidBooleanBoxedWithNumericBoxedType() { + void equalToOperationExpr_invalidBooleanBoxedWithNumericBoxedType() { // LHS: boolean boxed type, RHS: numeric // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNumericBoxedWithBooleanBoxedType". @@ -353,7 +353,7 @@ public void equalToOperationExpr_invalidBooleanBoxedWithNumericBoxedType() { } @Test - public void equalToOperationExpr_invalidBoxedBooleanWithReferencedType() { + void equalToOperationExpr_invalidBoxedBooleanWithReferencedType() { // LHS: boolean boxed type, RHS: reference type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidReferenceWithBooleanBoxedType". @@ -366,7 +366,7 @@ public void equalToOperationExpr_invalidBoxedBooleanWithReferencedType() { /** ===================== Equality Operators: LHS data type is Array ======================== */ @Test - public void equalToOperationExpr_validArrayWithMatchedType() { + void equalToOperationExpr_validArrayWithMatchedType() { // LHS: Array with numeric type, RHS: Array with matched numeric type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = @@ -380,7 +380,7 @@ public void equalToOperationExpr_validArrayWithMatchedType() { } @Test - public void equalToOperationExpr_validArrayWithNullType() { + void equalToOperationExpr_validArrayWithNullType() { // LHS: Array with numeric type, RHS: null // Swapping LHS and RHS test case is covered in "equalToOperationExpr_validANullWithArrayType". VariableExpr lhsExpr = @@ -393,7 +393,7 @@ public void equalToOperationExpr_validArrayWithNullType() { } @Test - public void notEqualToOperationExpr_invalidArrayWithUnmatchedType() { + void notEqualToOperationExpr_invalidArrayWithUnmatchedType() { // LHS: Array with numeric type, RHS: Array with unmatched numeric type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = @@ -408,7 +408,7 @@ public void notEqualToOperationExpr_invalidArrayWithUnmatchedType() { } @Test - public void equalToOperationExpr_invalidArrayWithNotArrayType() { + void equalToOperationExpr_invalidArrayWithNotArrayType() { // LHS: Array with numeric type, RHS: not Array // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNumericTypeWithArrayType". @@ -422,7 +422,7 @@ public void equalToOperationExpr_invalidArrayWithNotArrayType() { } @Test - public void equalToOperationExpr_invalidArrayWithObjectType() { + void equalToOperationExpr_invalidArrayWithObjectType() { // LHS: Array with numeric type, RHS: New Object type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidObjectTypeWithArray". @@ -437,7 +437,7 @@ public void equalToOperationExpr_invalidArrayWithObjectType() { /** ================== Equality Operators: LHS data type is reference type =================== */ @Test - public void equalToOperationExpr_validReferenceWithMatchedType() { + void equalToOperationExpr_validReferenceWithMatchedType() { // LHS: String type, RHS: matched String type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); @@ -447,7 +447,7 @@ public void equalToOperationExpr_validReferenceWithMatchedType() { } @Test - public void equalToOperationExpr_validReferenceWithNullType() { + void equalToOperationExpr_validReferenceWithNullType() { // LHS: String type, RHS: null. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNullWithReferenceType". @@ -458,7 +458,7 @@ public void equalToOperationExpr_validReferenceWithNullType() { } @Test - public void equalToOperationExpr_validReferenceWithObjectType() { + void equalToOperationExpr_validReferenceWithObjectType() { // LHS: String type, RHS: New object type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validObjectWithStringType". @@ -469,7 +469,7 @@ public void equalToOperationExpr_validReferenceWithObjectType() { } @Test - public void equalToOperationExpr_validAnyObjectTypeWithObject() { + void equalToOperationExpr_validAnyObjectTypeWithObject() { // LHS: Any reference type, RHS: Object type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validObjectWithAnyObjectType". @@ -486,7 +486,7 @@ public void equalToOperationExpr_validAnyObjectTypeWithObject() { } @Test - public void equalToOperationExpr_validAnyReferenceTypeWithNull() { + void equalToOperationExpr_validAnyReferenceTypeWithNull() { // LHS: Any reference type, RHS: Null type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNullWithAnyReferenceType". @@ -503,7 +503,7 @@ public void equalToOperationExpr_validAnyReferenceTypeWithNull() { } @Test - public void equalToOperationExpr_invalidReferenceWithUnmatchedReferenceType() { + void equalToOperationExpr_invalidReferenceWithUnmatchedReferenceType() { // LHS: String type, RHS: Unmatched reference type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); @@ -520,7 +520,7 @@ public void equalToOperationExpr_invalidReferenceWithUnmatchedReferenceType() { } @Test - public void equalToOperationExpr_invalidReferenceWithNumericType() { + void equalToOperationExpr_invalidReferenceWithNumericType() { // LHS: String type, RHS: Numeric type // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_invalidNumericStringType". @@ -532,7 +532,7 @@ public void equalToOperationExpr_invalidReferenceWithNumericType() { } @Test - public void equalToOperationExpr_invalidReferenceWithNumericBoxedType() { + void equalToOperationExpr_invalidReferenceWithNumericBoxedType() { // LHS: String type, RHS: numeric boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidNumericBoxedWithReferenceType". @@ -544,7 +544,7 @@ public void equalToOperationExpr_invalidReferenceWithNumericBoxedType() { } @Test - public void equalToOperationExpr_invalidReferenceWithBooleanType() { + void equalToOperationExpr_invalidReferenceWithBooleanType() { // LHS: String type, RHS: Boolean boxed type. // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_invalidBooleanToReferenceType". @@ -556,7 +556,7 @@ public void equalToOperationExpr_invalidReferenceWithBooleanType() { } @Test - public void equalToOperationExpr_invalidReferenceWithBooleanBoxedType() { + void equalToOperationExpr_invalidReferenceWithBooleanBoxedType() { // LHS: String type, RHS: Boolean boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidBoxedBooleanWithReferencedType". @@ -569,7 +569,7 @@ public void equalToOperationExpr_invalidReferenceWithBooleanBoxedType() { /** ================== Equality Operators: LHS data type is Object or null =================== */ @Test - public void equalToOperationExpr_validObjectWithAnyObjectType() { + void equalToOperationExpr_validObjectWithAnyObjectType() { // LHS: Object type, RHS: Any reference type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validAnyObjectTypeWithObject". @@ -586,7 +586,7 @@ public void equalToOperationExpr_validObjectWithAnyObjectType() { } @Test - public void equalToOperationExpr_validNullWithAnyReferenceType() { + void equalToOperationExpr_validNullWithAnyReferenceType() { // LHS: Null type, RHS: any reference type // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validAnyReferenceTypeWithNull". @@ -603,7 +603,7 @@ public void equalToOperationExpr_validNullWithAnyReferenceType() { } @Test - public void equalToOperationExpr_validObjectWithNullType() { + void equalToOperationExpr_validObjectWithNullType() { // LHS: Object, RHS: Null. // Swapping LHS and RHS test case is covered in "equalToOperationExpr_validNullWithObjectType". VariableExpr lhsExpr = createVariableExpr(TypeNode.OBJECT, "x"); @@ -613,7 +613,7 @@ public void equalToOperationExpr_validObjectWithNullType() { } @Test - public void equalToOperationExpr_validNullWithObjectType() { + void equalToOperationExpr_validNullWithObjectType() { // LHS: Null, RHS: Object. // Swapping LHS and RHS test case is covered in "equalToOperationExpr_validObjectWithNullType". VariableExpr rhsExpr = createVariableExpr(TypeNode.OBJECT, "x"); @@ -623,7 +623,7 @@ public void equalToOperationExpr_validNullWithObjectType() { } @Test - public void equalToOperationExpr_validNullWithNullType() { + void equalToOperationExpr_validNullWithNullType() { // LHS: Null, RHS: Null. // No need swap LHS and RHS test case. ValueExpr lhsExpr = ValueExpr.createNullExpr(); @@ -633,7 +633,7 @@ public void equalToOperationExpr_validNullWithNullType() { } @Test - public void equalToOperationExpr_validObjectWithStringType() { + void equalToOperationExpr_validObjectWithStringType() { // LHS: Object type, RHS: Reference type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validReferenceWithObjectType". @@ -644,7 +644,7 @@ public void equalToOperationExpr_validObjectWithStringType() { } @Test - public void equalToOperationExpr_validObjectWithBooleanBoxedType() { + void equalToOperationExpr_validObjectWithBooleanBoxedType() { // LHS: Object type, RHS: Boolean boxed type. // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_validBooleanBoxedToObjectType". @@ -655,7 +655,7 @@ public void equalToOperationExpr_validObjectWithBooleanBoxedType() { } @Test - public void equalToOperationExpr_validObjectWithNumericBoxedType() { + void equalToOperationExpr_validObjectWithNumericBoxedType() { // LHS: Object type, RHS: Any Boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNumericBoxedWithNewObjectType". @@ -666,7 +666,7 @@ public void equalToOperationExpr_validObjectWithNumericBoxedType() { } @Test - public void equalToOperationExpr_validNullWithReferenceType() { + void equalToOperationExpr_validNullWithReferenceType() { // LHS: Null type, RHS: Reference type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNullWithReferenceType". @@ -677,7 +677,7 @@ public void equalToOperationExpr_validNullWithReferenceType() { } @Test - public void equalToOperationExpr_validNullWithBooleanBoxedType() { + void equalToOperationExpr_validNullWithBooleanBoxedType() { // LHS: Object type, RHS: Any Boxed type // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_validBooleanBoxedToNullType". @@ -688,7 +688,7 @@ public void equalToOperationExpr_validNullWithBooleanBoxedType() { } @Test - public void equalToOperationExpr_validNullWithNumericBoxedType() { + void equalToOperationExpr_validNullWithNumericBoxedType() { // LHS: Object type, RHS: Any Boxed type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_validNumericBoxedWithNullType". @@ -699,7 +699,7 @@ public void equalToOperationExpr_validNullWithNumericBoxedType() { } @Test - public void equalToOperationExpr_validANullWithArrayType() { + void equalToOperationExpr_validANullWithArrayType() { // LHS: Null, RHS: Array with numeric type. // Swapping LHS and RHS test case is covered in "equalToOperationExpr_validArrayWithNullType". NullObjectValue nullObjectValue = NullObjectValue.create(); @@ -712,7 +712,7 @@ public void equalToOperationExpr_validANullWithArrayType() { } @Test - public void equalToOperationExpr_invalidNullWithNumericType() { + void equalToOperationExpr_invalidNullWithNumericType() { // LHS: Null type, RHS: Nny Numeric type. // Swapping LHS and RHS test case is covered in // "notEqualToOperationExpr_invalidNumericNullType". @@ -724,7 +724,7 @@ public void equalToOperationExpr_invalidNullWithNumericType() { } @Test - public void equalToOperationExpr_invalidNullWithBooleanType() { + void equalToOperationExpr_invalidNullWithBooleanType() { // LHS: Null type, RHS: Boolean type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidBooleanWithNullType". @@ -736,7 +736,7 @@ public void equalToOperationExpr_invalidNullWithBooleanType() { } @Test - public void equalToOperationExpr_invalidObjectWithNumericType() { + void equalToOperationExpr_invalidObjectWithNumericType() { // LHS: Object type, RHS: Any Numeric type. VariableExpr lhsExpr = createVariableExpr(TypeNode.OBJECT, "x"); VariableExpr rhsExpr = createVariableExpr(TypeNode.DOUBLE, "y"); @@ -746,7 +746,7 @@ public void equalToOperationExpr_invalidObjectWithNumericType() { } @Test - public void equalToOperationExpr_invalidObjectWithBooleanType() { + void equalToOperationExpr_invalidObjectWithBooleanType() { // LHS: Object type, RHS: Boolean type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidBooleanWithObjectType". @@ -758,7 +758,7 @@ public void equalToOperationExpr_invalidObjectWithBooleanType() { } @Test - public void equalToOperationExpr_invalidObjectTypeWithArray() { + void equalToOperationExpr_invalidObjectTypeWithArray() { // LHS: New Object type, RHS: Array with numeric type. // Swapping LHS and RHS test case is covered in // "equalToOperationExpr_invalidArrayWithObjectType". @@ -774,7 +774,7 @@ public void equalToOperationExpr_invalidObjectTypeWithArray() { /** ================== Less Than Operators: expr types are numeric types =================== */ // The expression types on LHS or RHS could be any numeric type or any numeric boxed type. @Test - public void lessThanOperationExpr_validMatchedNumericType() { + void lessThanOperationExpr_validMatchedNumericType() { // LHS: Numeric type, RHS: Matched numeric type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); @@ -784,7 +784,7 @@ public void lessThanOperationExpr_validMatchedNumericType() { } @Test - public void lessThanOperationExpr_validUnmatchedNumericType() { + void lessThanOperationExpr_validUnmatchedNumericType() { // LHS: Numeric type, RHS: Unmatched numeric type. // No need swap LHS and RHS test case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); @@ -794,7 +794,7 @@ public void lessThanOperationExpr_validUnmatchedNumericType() { } @Test - public void lessThanOperationExpr_validMatchedNumericBoxedType() { + void lessThanOperationExpr_validMatchedNumericBoxedType() { // LHS: Numeric type, RHS: Matched numeric type. // Swap case in "lessThanOperationExpr_validNumericBoxedTypeWithMatchedNumericType". VariableExpr lhsExpr = createVariableExpr(TypeNode.FLOAT, "x"); @@ -804,7 +804,7 @@ public void lessThanOperationExpr_validMatchedNumericBoxedType() { } @Test - public void lessThanOperationExpr_validNumericBoxedTypeWithMatchedNumericType() { + void lessThanOperationExpr_validNumericBoxedTypeWithMatchedNumericType() { // LHS: Numeric boxed type, RHS: Matched numeric type. // Swap case in "lessThanOperationExpr_validMatchedNumericBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.CHAR_OBJECT, "x"); @@ -814,7 +814,7 @@ public void lessThanOperationExpr_validNumericBoxedTypeWithMatchedNumericType() } @Test - public void lessThanOperationExpr_validUnmatchedNumericBoxedType() { + void lessThanOperationExpr_validUnmatchedNumericBoxedType() { // LHS: Numeric type, RHS: Unmatched numeric boxed type. // Swap case in "lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedUnBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE, "x"); @@ -824,7 +824,7 @@ public void lessThanOperationExpr_validUnmatchedNumericBoxedType() { } @Test - public void lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedUnBoxedType() { + void lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedUnBoxedType() { // LHS: Numeric boxed type, RHS: Unmatched numeric type. // Swap case in "lessThanOperationExpr_validUnmatchedNumericBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -834,7 +834,7 @@ public void lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedUnBoxedType( } @Test - public void lessThanOperationExpr_validNumericBoxedTypeWithMatchedBoxedType() { + void lessThanOperationExpr_validNumericBoxedTypeWithMatchedBoxedType() { // LHS: Numeric boxed type, RHS: Matched numeric boxed type. // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -844,7 +844,7 @@ public void lessThanOperationExpr_validNumericBoxedTypeWithMatchedBoxedType() { } @Test - public void lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedBoxedType() { + void lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedBoxedType() { // LHS: Numeric boxed type, RHS: Unmatched numeric boxed type. // No need swap case. VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -856,7 +856,7 @@ public void lessThanOperationExpr_validNumericBoxedTypeWithUnmatchedBoxedType() /** ================= Less Than Operators: expr types are non-numeric types ================== */ // Invalid if any of expression type on LHS or RHS is non-numeric type or non numeric boxed type. @Test - public void lessThanOperationExpr_invalidNumericTypeWithNullType() { + void lessThanOperationExpr_invalidNumericTypeWithNullType() { // LHS: Null type, RHS: Numeric type. // Swap case in "lessThanOperationExpr_invalidNumericWithNullType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); @@ -867,7 +867,7 @@ public void lessThanOperationExpr_invalidNumericTypeWithNullType() { } @Test - public void lessThanOperationExpr_invalidNumericBoxedTypeWithNullType() { + void lessThanOperationExpr_invalidNumericBoxedTypeWithNullType() { // LHS: Numeric boxed type, RHS: Null type. // Swap case in "lessThanOperationExpr_invalidNullWithNumericBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -878,7 +878,7 @@ public void lessThanOperationExpr_invalidNumericBoxedTypeWithNullType() { } @Test - public void lessThanOperationExpr_invalidNumericTypeWithObjectType() { + void lessThanOperationExpr_invalidNumericTypeWithObjectType() { // LHS: Numeric type, RHS: Object Type. // Swap case in "lessThanOperationExpr_invalidObjectNumericType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x"); @@ -889,7 +889,7 @@ public void lessThanOperationExpr_invalidNumericTypeWithObjectType() { } @Test - public void lessThanOperationExpr_invalidNumericBoxedTypeWithObjectType() { + void lessThanOperationExpr_invalidNumericBoxedTypeWithObjectType() { // LHS: Numeric boxed type, RHS: Object Type. // Swap case in "lessThanOperationExpr_invalidObjectNumericBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -900,7 +900,7 @@ public void lessThanOperationExpr_invalidNumericBoxedTypeWithObjectType() { } @Test - public void lessThanOperationExpr_invalidNumericBoxedTypeWithReferenceType() { + void lessThanOperationExpr_invalidNumericBoxedTypeWithReferenceType() { // LHS: Numeric boxed type, RHS: Reference Type. // Swap case in "lessThanOperationExpr_invalidReferenceTypeWithNumericBoxedType". VariableExpr lhsExpr = createVariableExpr(TypeNode.INT_OBJECT, "x"); @@ -911,7 +911,7 @@ public void lessThanOperationExpr_invalidNumericBoxedTypeWithReferenceType() { } @Test - public void lessThanOperationExpr_invalidReferenceTypeWithNumericBoxedType() { + void lessThanOperationExpr_invalidReferenceTypeWithNumericBoxedType() { // LHS: Reference type, RHS: Numeric boxed Type. // Swap case in "lessThanOperationExpr_invalidNumericBoxedTypeWithReferenceType". VariableExpr lhsExpr = createVariableExpr(TypeNode.STRING, "x"); @@ -922,7 +922,7 @@ public void lessThanOperationExpr_invalidReferenceTypeWithNumericBoxedType() { } @Test - public void lessThanOperationExpr_invalidObjectNumericType() { + void lessThanOperationExpr_invalidObjectNumericType() { // LHS: Object type, RHS: Numeric Type. // Swap case in "lessThanOperationExpr_invalidNumericTypeWithObjectType". NewObjectExpr lhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -933,7 +933,7 @@ public void lessThanOperationExpr_invalidObjectNumericType() { } @Test - public void lessThanOperationExpr_invalidObjectNumericBoxedType() { + void lessThanOperationExpr_invalidObjectNumericBoxedType() { // LHS: Object type, RHS: Numeric boxed Type. // Swap case in "lessThanOperationExpr_invalidNumericBoxedTypeWithObjectType". NewObjectExpr lhsExpr = NewObjectExpr.withType(TypeNode.OBJECT); @@ -944,7 +944,7 @@ public void lessThanOperationExpr_invalidObjectNumericBoxedType() { } @Test - public void lessThanOperationExpr_invalidNumericWithNullType() { + void lessThanOperationExpr_invalidNumericWithNullType() { // LHS: Null type, RHS: Numeric box type. ValueExpr lhsExpr = ValueExpr.createNullExpr(); @@ -955,7 +955,7 @@ public void lessThanOperationExpr_invalidNumericWithNullType() { } @Test - public void lessThanOperationExpr_invalidNullWithNumericBoxedType() { + void lessThanOperationExpr_invalidNullWithNumericBoxedType() { // LHS: Null type, RHS: Numeric box type. // Swap case in "lessThanOperationExpr_invalidNumericTypeWithNullType". ValueExpr lhsExpr = ValueExpr.createNullExpr(); @@ -966,7 +966,7 @@ public void lessThanOperationExpr_invalidNullWithNumericBoxedType() { } @Test - public void lessThanOperationExpr_invalidVoidType() { + void lessThanOperationExpr_invalidVoidType() { // LHS: Null type, RHS: Numeric box type. // No need swap case MethodInvocationExpr lhsExpr = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReturnExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReturnExprTest.java index 260c5955f7..cb570034b3 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReturnExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ReturnExprTest.java @@ -16,17 +16,17 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ReturnExprTest { +class ReturnExprTest { @Test - public void validReturnExpr_basic() { + void validReturnExpr_basic() { ReturnExpr.withExpr(ValueExpr.withValue(StringObjectValue.withValue("asdf"))); // No exception thrown, we're good. } @Test - public void invalidReturnExpr_nestedReturnExpr() { + void invalidReturnExpr_nestedReturnExpr() { ReturnExpr returnExpr = ReturnExpr.withExpr(ValueExpr.withValue(StringObjectValue.withValue("asdf"))); assertThrows(IllegalStateException.class, () -> ReturnExpr.withExpr(returnExpr)); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/StringObjectValueTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/StringObjectValueTest.java index 1f29f92b14..8d7d92db0f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/StringObjectValueTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/StringObjectValueTest.java @@ -16,19 +16,19 @@ import static com.google.common.truth.Truth.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class StringObjectValueTest { +class StringObjectValueTest { @Test - public void createStringObjectValue_basic() { + void createStringObjectValue_basic() { StringObjectValue s = StringObjectValue.builder().setValue("test").build(); assertThat(s.value()).isEqualTo("\"test\""); assertThat(s.type()).isEqualTo(TypeNode.STRING); } @Test - public void createStringObjectValue_escapeCharacter() { + void createStringObjectValue_escapeCharacter() { StringObjectValue valueSpecialChar = StringObjectValue.withValue("\" \t \\ \b \r \f \n '"); String expected = "\"\\\" \\t \\\\ \\b \\r \\f \\n '\""; assertThat(valueSpecialChar.value()).isEqualTo(expected); @@ -36,7 +36,7 @@ public void createStringObjectValue_escapeCharacter() { } @Test - public void createStringObjectValue_specialCharacter() { + void createStringObjectValue_specialCharacter() { StringObjectValue valueSpecialChar = StringObjectValue.withValue("Tom said: \"Hi!\"; \n"); String expected = "\"Tom said: \\\"Hi!\\\"; \\n\""; assertThat(valueSpecialChar.value()).isEqualTo(expected); @@ -44,7 +44,7 @@ public void createStringObjectValue_specialCharacter() { } @Test - public void createStringObjectValue_specialCharacterComment() { + void createStringObjectValue_specialCharacterComment() { StringObjectValue valueSpecialChar = StringObjectValue.withValue("Service comment may include special characters: <>&\"`'@"); String expected = "\"Service comment may include special characters: <>&\\\"`'@\""; @@ -53,7 +53,7 @@ public void createStringObjectValue_specialCharacterComment() { } @Test - public void createStringObjectValue_usPunctuation() { + void createStringObjectValue_usPunctuation() { StringObjectValue valueSpecialChar = StringObjectValue.withValue("US Punctuation, one of !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"); String expected = "\"US Punctuation, one of !\\\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~\""; @@ -62,7 +62,7 @@ public void createStringObjectValue_usPunctuation() { } @Test - public void createStringObjectValue_htmlCharacterComment() { + void createStringObjectValue_htmlCharacterComment() { StringObjectValue valueSpecialChar = StringObjectValue.withValue("  ( [ – >:<"); String expected = "\"  ( [ – >:<\""; diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SuperObjectValueTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SuperObjectValueTest.java index 3c7a264ca9..1e06bec08c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SuperObjectValueTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SuperObjectValueTest.java @@ -16,12 +16,12 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SuperObjectValueTest { +class SuperObjectValueTest { @Test - public void validSuperObjectValue_basic() { + void validSuperObjectValue_basic() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -33,7 +33,7 @@ public void validSuperObjectValue_basic() { } @Test - public void invalidSuperObjectValue_nonReferenceType() { + void invalidSuperObjectValue_nonReferenceType() { assertThrows( IllegalStateException.class, () -> { @@ -42,7 +42,7 @@ public void invalidSuperObjectValue_nonReferenceType() { } @Test - public void invalidSuperObjectValue_nullType() { + void invalidSuperObjectValue_nullType() { assertThrows( IllegalStateException.class, () -> { diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SynchronizedStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SynchronizedStatementTest.java index f7957d03e3..67a6a1c6c6 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SynchronizedStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/SynchronizedStatementTest.java @@ -16,11 +16,11 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SynchronizedStatementTest { +class SynchronizedStatementTest { @Test - public void validSynchronizedStatement_basicThis() { + void validSynchronizedStatement_basicThis() { SynchronizedStatement.builder() .setLock( ThisObjectValue.withType( @@ -31,7 +31,7 @@ public void validSynchronizedStatement_basicThis() { } @Test - public void validSynchronizedStatement_basicVariableExpr() { + void validSynchronizedStatement_basicVariableExpr() { SynchronizedStatement.builder() .setLock( VariableExpr.withVariable( @@ -42,7 +42,7 @@ public void validSynchronizedStatement_basicVariableExpr() { } @Test - public void invalidSynchronizedStatement_primitiveLock() { + void invalidSynchronizedStatement_primitiveLock() { assertThrows( IllegalStateException.class, () -> @@ -57,7 +57,7 @@ public void invalidSynchronizedStatement_primitiveLock() { } @Test - public void invalidSynchronizedStatement_declaredVariableExpr() { + void invalidSynchronizedStatement_declaredVariableExpr() { VariableExpr strVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("str").setType(TypeNode.STRING).build()) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TernaryExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TernaryExprTest.java index 9cde2c39d3..153fb797ba 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TernaryExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TernaryExprTest.java @@ -17,11 +17,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TernaryExprTest { +class TernaryExprTest { @Test - public void validTernaryExpr_primitiveType() { + void validTernaryExpr_primitiveType() { Variable conditionVariable = Variable.builder().setName("condition").setType(TypeNode.BOOLEAN).build(); VariableExpr conditionExpr = VariableExpr.builder().setVariable(conditionVariable).build(); @@ -43,7 +43,7 @@ public void validTernaryExpr_primitiveType() { } @Test - public void validTernaryExpr_objectType() { + void validTernaryExpr_objectType() { Variable conditionVariable = Variable.builder().setName("condition").setType(TypeNode.BOOLEAN).build(); VariableExpr conditionExpr = VariableExpr.builder().setVariable(conditionVariable).build(); @@ -65,7 +65,7 @@ public void validTernaryExpr_objectType() { } @Test - public void validTernaryExpr_primitiveAndBoxedType() { + void validTernaryExpr_primitiveAndBoxedType() { // [Constructing] `condition ? intValue : integerValue` // The type of whole expression should be Integer. Variable conditionVariable = @@ -88,7 +88,7 @@ public void validTernaryExpr_primitiveAndBoxedType() { } @Test - public void validTernaryExpr_boxedAndPrimitiveType() { + void validTernaryExpr_boxedAndPrimitiveType() { // [Constructing] `condition ? doubleObjectVariable : doubleVariable` // The type of whole expression should be Double. Variable conditionVariable = @@ -112,7 +112,7 @@ public void validTernaryExpr_boxedAndPrimitiveType() { } @Test - public void validTernaryExpr_objectAndNull() { + void validTernaryExpr_objectAndNull() { TernaryExpr ternaryExpr = TernaryExpr.builder() .setConditionExpr( @@ -126,7 +126,7 @@ public void validTernaryExpr_objectAndNull() { } @Test - public void validTernaryExpr_nullAndObject() { + void validTernaryExpr_nullAndObject() { TernaryExpr ternaryExpr = TernaryExpr.builder() .setConditionExpr( @@ -140,7 +140,7 @@ public void validTernaryExpr_nullAndObject() { } @Test - public void validTernaryExpr_superAndSubtype() { + void validTernaryExpr_superAndSubtype() { TernaryExpr ternaryExpr = TernaryExpr.builder() .setConditionExpr( @@ -156,7 +156,7 @@ public void validTernaryExpr_superAndSubtype() { } @Test - public void validTernaryExpr_subAndSupertype() { + void validTernaryExpr_subAndSupertype() { TernaryExpr ternaryExpr = TernaryExpr.builder() .setConditionExpr( @@ -172,7 +172,7 @@ public void validTernaryExpr_subAndSupertype() { } @Test - public void invalidTernaryExpr_mismatchedPrimitiveTypes() { + void invalidTernaryExpr_mismatchedPrimitiveTypes() { Variable conditionVariable = Variable.builder().setName("condition").setType(TypeNode.BOOLEAN).build(); VariableExpr conditionExpr = VariableExpr.builder().setVariable(conditionVariable).build(); @@ -193,7 +193,7 @@ public void invalidTernaryExpr_mismatchedPrimitiveTypes() { } @Test - public void invalidTernaryExpr_mismatchedBoxedAndPrimitiveTypes() { + void invalidTernaryExpr_mismatchedBoxedAndPrimitiveTypes() { Variable conditionVariable = Variable.builder().setName("condition").setType(TypeNode.BOOLEAN).build(); VariableExpr conditionExpr = VariableExpr.builder().setVariable(conditionVariable).build(); @@ -216,7 +216,7 @@ public void invalidTernaryExpr_mismatchedBoxedAndPrimitiveTypes() { } @Test - public void invalidTernaryExpr_incompatibleThenElsePrimitiveTypes() { + void invalidTernaryExpr_incompatibleThenElsePrimitiveTypes() { assertThrows( IllegalStateException.class, () -> @@ -238,7 +238,7 @@ public void invalidTernaryExpr_incompatibleThenElsePrimitiveTypes() { } @Test - public void invalidTernaryExpr_incompatibleThenElseObjectTypes() { + void invalidTernaryExpr_incompatibleThenElseObjectTypes() { assertThrows( IllegalStateException.class, () -> diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThisObjectValueTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThisObjectValueTest.java index 83e7c75ab8..870f4fb7af 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThisObjectValueTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThisObjectValueTest.java @@ -16,11 +16,11 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ThisObjectValueTest { +class ThisObjectValueTest { @Test - public void validThisObjectValue_basic() { + void validThisObjectValue_basic() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -32,7 +32,7 @@ public void validThisObjectValue_basic() { } @Test - public void invalidThisObjectValue_nonReferenceType() { + void invalidThisObjectValue_nonReferenceType() { assertThrows( IllegalStateException.class, () -> { @@ -41,7 +41,7 @@ public void invalidThisObjectValue_nonReferenceType() { } @Test - public void invalidThisObjectValue_nullType() { + void invalidThisObjectValue_nullType() { assertThrows( IllegalStateException.class, () -> { diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThrowExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThrowExprTest.java index cc4b38f3df..e4baf14fc1 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThrowExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/ThrowExprTest.java @@ -17,18 +17,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ThrowExprTest { +class ThrowExprTest { @Test - public void createThrowExpr_basic() { + void createThrowExpr_basic() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); ThrowExpr.builder().setType(npeType).build(); // No exception thrown, we're good. } @Test - public void createThrowExpr_basicExpr() { + void createThrowExpr_basicExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); VariableExpr throwVarExpr = VariableExpr.builder() @@ -46,14 +46,14 @@ public void createThrowExpr_basicExpr() { } @Test - public void createThrowExpr_basicWithStringMessage() { + void createThrowExpr_basicWithStringMessage() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); ThrowExpr.builder().setType(npeType).setMessageExpr("Some message").build(); // No exception thrown, we're good. } @Test - public void createThrowExpr_messageExpr() { + void createThrowExpr_messageExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); Expr messageExpr = MethodInvocationExpr.builder() @@ -65,14 +65,14 @@ public void createThrowExpr_messageExpr() { } @Test - public void createThrowExpr_badExceptionType() { + void createThrowExpr_badExceptionType() { TypeNode nonExceptionType = TypeNode.STRING; assertThrows( IllegalStateException.class, () -> ThrowExpr.builder().setType(nonExceptionType).build()); } @Test - public void createThrowExpr_badMessageExpr() { + void createThrowExpr_badMessageExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); Expr messageExpr = MethodInvocationExpr.builder().setMethodName("foobar").setReturnType(TypeNode.INT).build(); @@ -82,7 +82,7 @@ public void createThrowExpr_badMessageExpr() { } @Test - public void createThrowExpr_causeExpr() { + void createThrowExpr_causeExpr() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); ThrowExpr.builder() @@ -96,7 +96,7 @@ public void createThrowExpr_causeExpr() { } @Test - public void createThrowExpr_causeExpr_throwableSubtype() { + void createThrowExpr_causeExpr_throwableSubtype() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); ThrowExpr.builder() @@ -110,7 +110,7 @@ public void createThrowExpr_causeExpr_throwableSubtype() { } @Test - public void createThrowExpr_causeExpr_onThrowableSubtype() { + void createThrowExpr_causeExpr_onThrowableSubtype() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); assertThrows( @@ -123,7 +123,7 @@ public void createThrowExpr_causeExpr_onThrowableSubtype() { } @Test - public void createThrowExpr_messageAndCauseExpr() { + void createThrowExpr_messageAndCauseExpr() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); Expr messageExpr = @@ -143,7 +143,7 @@ public void createThrowExpr_messageAndCauseExpr() { } @Test - public void createThrowExpr_cannotThrowVariableDeclaration() { + void createThrowExpr_cannotThrowVariableDeclaration() { VariableExpr throwVarExpr = VariableExpr.builder() .setVariable( @@ -161,7 +161,7 @@ public void createThrowExpr_cannotThrowVariableDeclaration() { } @Test - public void createThrowExpr_cannotThrowNonExceptionTypedExpr() { + void createThrowExpr_cannotThrowNonExceptionTypedExpr() { VariableExpr throwVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("str").setType(TypeNode.STRING).build()) @@ -171,7 +171,7 @@ public void createThrowExpr_cannotThrowNonExceptionTypedExpr() { } @Test - public void createThrowExpr_cannotHaveThrowVariableAndMessageExprPresent() { + void createThrowExpr_cannotHaveThrowVariableAndMessageExprPresent() { Expr messageExpr = MethodInvocationExpr.builder() .setMethodName("foobar") @@ -191,7 +191,7 @@ public void createThrowExpr_cannotHaveThrowVariableAndMessageExprPresent() { } @Test - public void createThrowExpr_cannotHaveThrowVariableAndCauseExprPresent() { + void createThrowExpr_cannotHaveThrowVariableAndCauseExprPresent() { VariableExpr throwVarExpr = VariableExpr.builder() .setVariable( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TryCatchStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TryCatchStatementTest.java index 9837c192f5..efa02ee2a8 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TryCatchStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TryCatchStatementTest.java @@ -20,12 +20,12 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TryCatchStatementTest { +class TryCatchStatementTest { @Test - public void validTryCatchStatement_simple() { + void validTryCatchStatement_simple() { Reference exceptionReference = ConcreteReference.withClazz(IllegalArgumentException.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = @@ -41,7 +41,7 @@ public void validTryCatchStatement_simple() { } @Test - public void validTryCatchStatement_simpleMultiBlock() { + void validTryCatchStatement_simpleMultiBlock() { VariableExpr firstCatchVarExpr = VariableExpr.builder() .setVariable( @@ -67,7 +67,7 @@ public void validTryCatchStatement_simpleMultiBlock() { } @Test - public void validTryCatchStatement_withResources() { + void validTryCatchStatement_withResources() { Reference exceptionReference = ConcreteReference.withClazz(IllegalArgumentException.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = @@ -85,7 +85,7 @@ public void validTryCatchStatement_withResources() { } @Test - public void validTryCatchStatement_sampleCode() { + void validTryCatchStatement_sampleCode() { TryCatchStatement tryCatch = TryCatchStatement.builder() .setTryBody(Arrays.asList(ExprStatement.withExpr(createAssignmentExpr()))) @@ -95,7 +95,7 @@ public void validTryCatchStatement_sampleCode() { } @Test - public void invalidTryCatchStatement_missingCatchVariable() { + void invalidTryCatchStatement_missingCatchVariable() { assertThrows( IllegalStateException.class, () -> @@ -105,7 +105,7 @@ public void invalidTryCatchStatement_missingCatchVariable() { } @Test - public void invalidTryCatchStatement_catchVariableNotDecl() { + void invalidTryCatchStatement_catchVariableNotDecl() { Reference exceptionReference = ConcreteReference.withClazz(IllegalArgumentException.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = @@ -121,7 +121,7 @@ public void invalidTryCatchStatement_catchVariableNotDecl() { } @Test - public void invalidTryCatchStatement_nonExceptionReference() { + void invalidTryCatchStatement_nonExceptionReference() { Reference exceptionReference = ConcreteReference.withClazz(Integer.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TypeNodeTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TypeNodeTest.java index 5b80fdedc0..4977a5b877 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TypeNodeTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/TypeNodeTest.java @@ -22,9 +22,9 @@ import com.google.api.generator.engine.ast.TypeNode.TypeKind; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TypeNodeTest { +class TypeNodeTest { private static final TypeNode INT_ARRAY = TypeNode.builder().setTypeKind(TypeKind.INT).setIsArray(true).build(); private static final TypeNode INTEGER_ARRAY = @@ -37,7 +37,7 @@ public class TypeNodeTest { TypeNode.builder().setTypeKind(TypeKind.BOOLEAN).setIsArray(true).build(); @Test - public void strictEquals_basic() { + void strictEquals_basic() { assertFalse(TypeNode.INT.strictEquals(TypeNode.BOOLEAN)); assertFalse(TypeNode.CHAR.strictEquals(TypeNode.NULL)); assertFalse(TypeNode.INT.strictEquals(INT_ARRAY)); @@ -45,7 +45,7 @@ public void strictEquals_basic() { } @Test - public void strictEquals_referenceType() { + void strictEquals_referenceType() { TypeNode list = TypeNode.withReference(ConcreteReference.withClazz(List.class)); TypeNode intList = TypeNode.withReference( @@ -64,7 +64,7 @@ public void strictEquals_referenceType() { } @Test - public void isBoxedTypeEquals_basic() { + void isBoxedTypeEquals_basic() { assertTrue(TypeNode.INT.isBoxedTypeEquals(TypeNode.INT_OBJECT)); assertTrue(TypeNode.DOUBLE_OBJECT.isBoxedTypeEquals(TypeNode.DOUBLE)); assertFalse(TypeNode.BOOLEAN_OBJECT.isBoxedTypeEquals(TypeNode.SHORT)); @@ -73,14 +73,14 @@ public void isBoxedTypeEquals_basic() { } @Test - public void isBoxedTypeEquals_arrayType() { + void isBoxedTypeEquals_arrayType() { assertFalse(TypeNode.INT.isBoxedTypeEquals(INT_ARRAY)); assertFalse(INTEGER_ARRAY.isBoxedTypeEquals(INT_ARRAY)); assertFalse(BOOLEAN_ARRAY.isBoxedTypeEquals(INT_ARRAY)); } @Test - public void equals_basic() { + void equals_basic() { assertTrue(TypeNode.INT.equals(TypeNode.INT_OBJECT)); assertTrue(TypeNode.DOUBLE_OBJECT.equals(TypeNode.DOUBLE)); assertTrue(TypeNode.BOOLEAN.equals(TypeNode.BOOLEAN)); @@ -92,7 +92,7 @@ public void equals_basic() { } @Test - public void type_wildcardGenerics() { + void type_wildcardGenerics() { // No exception thrown equates to success. TypeNode.withReference( ConcreteReference.builder() @@ -102,7 +102,7 @@ public void type_wildcardGenerics() { } @Test - public void type_wildcardUpperBoundGenerics() { + void type_wildcardUpperBoundGenerics() { // No exception thrown equates to success. TypeNode.withReference( ConcreteReference.builder() @@ -114,7 +114,7 @@ public void type_wildcardUpperBoundGenerics() { } @Test - public void compareTypes() { + void compareTypes() { // Primitive and primitive. // Can't compare objects to themselves, so this test is omitted. assertThat(TypeNode.INT.compareTo(TypeNode.BOOLEAN)).isGreaterThan(0); @@ -144,13 +144,13 @@ public void compareTypes() { } @Test - public void invalidType_topLevelWildcard() { + void invalidType_topLevelWildcard() { assertThrows( IllegalStateException.class, () -> TypeNode.withReference(ConcreteReference.wildcard())); } @Test - public void isBoxedType_basic() { + void isBoxedType_basic() { assertTrue(TypeNode.isBoxedType(TypeNode.INT_OBJECT)); assertTrue(TypeNode.isBoxedType(TypeNode.BOOLEAN_OBJECT)); assertTrue(TypeNode.isBoxedType(TypeNode.DOUBLE_OBJECT)); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/UnaryOperationExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/UnaryOperationExprTest.java index b1a45f5312..fc1fecfa2f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/UnaryOperationExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/UnaryOperationExprTest.java @@ -16,12 +16,12 @@ import static org.junit.Assert.assertThrows; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class UnaryOperationExprTest { +class UnaryOperationExprTest { /** =============================== Logic Not Operation Expr =============================== */ @Test - public void validLogicalNotOperationExpr_basic() { + void validLogicalNotOperationExpr_basic() { VariableExpr variableExpr = VariableExpr.withVariable( Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build()); @@ -30,7 +30,7 @@ public void validLogicalNotOperationExpr_basic() { } @Test - public void validLogicalNot_boxedType() { + void validLogicalNot_boxedType() { VariableExpr variableExpr = VariableExpr.withVariable( Variable.builder().setName("x").setType(TypeNode.BOOLEAN_OBJECT).build()); @@ -39,7 +39,7 @@ public void validLogicalNot_boxedType() { } @Test - public void invalidLogicalNot_numericType() { + void invalidLogicalNot_numericType() { VariableExpr variableExpr = VariableExpr.withVariable(Variable.builder().setName("x").setType(TypeNode.INT).build()); assertThrows( @@ -47,7 +47,7 @@ public void invalidLogicalNot_numericType() { } @Test - public void invalidLogicalNot_referenceType() { + void invalidLogicalNot_referenceType() { VariableExpr variableExpr = VariableExpr.withVariable(Variable.builder().setName("x").setType(TypeNode.STRING).build()); assertThrows( @@ -58,7 +58,7 @@ public void invalidLogicalNot_referenceType() { * =============================== Post Increment Operation Expr =============================== */ @Test - public void validPostIncrement_basic() { + void validPostIncrement_basic() { VariableExpr variableExpr = VariableExpr.withVariable(Variable.builder().setName("x").setType(TypeNode.INT).build()); UnaryOperationExpr.postfixIncrementWithExpr(variableExpr); @@ -66,7 +66,7 @@ public void validPostIncrement_basic() { } @Test - public void validPostIncrement_boxedType() { + void validPostIncrement_boxedType() { VariableExpr variableExpr = VariableExpr.withVariable( Variable.builder().setName("x").setType(TypeNode.FLOAT_OBJECT).build()); @@ -75,7 +75,7 @@ public void validPostIncrement_boxedType() { } @Test - public void invalidPostIncrement_boxedBooleanType() { + void invalidPostIncrement_boxedBooleanType() { VariableExpr variableExpr = VariableExpr.withVariable( Variable.builder().setName("x").setType(TypeNode.BOOLEAN_OBJECT).build()); @@ -85,7 +85,7 @@ public void invalidPostIncrement_boxedBooleanType() { } @Test - public void invalidPostIncrement_referenceType() { + void invalidPostIncrement_referenceType() { VariableExpr variableExpr = VariableExpr.withVariable(Variable.builder().setName("x").setType(TypeNode.STRING).build()); assertThrows( @@ -94,7 +94,7 @@ public void invalidPostIncrement_referenceType() { } @Test - public void invalidPostIncrement_finalVariable() { + void invalidPostIncrement_finalVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setIsFinal(true).setVariable(variable).build(); @@ -104,7 +104,7 @@ public void invalidPostIncrement_finalVariable() { } @Test - public void invalidPostIncrement_declaredVariable() { + void invalidPostIncrement_declaredVariable() { Variable variable = Variable.builder().setName("i").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setIsDecl(true).setVariable(variable).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VaporReferenceTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VaporReferenceTest.java index 486bc2efab..598a40c087 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VaporReferenceTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VaporReferenceTest.java @@ -18,11 +18,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class VaporReferenceTest { +class VaporReferenceTest { @Test - public void basic() { + void basic() { String pkg = "com.google.example.examples.library.v1"; String name = "Babbage"; Reference ref = VaporReference.builder().setName(name).setPakkage(pkg).build(); @@ -34,7 +34,7 @@ public void basic() { } @Test - public void basic_isStaticImport() { + void basic_isStaticImport() { String pkg = "com.google.example.examples.library.v1"; String name = "Babbage"; Reference ref = @@ -49,7 +49,7 @@ public void basic_isStaticImport() { } @Test - public void basic_nested() { + void basic_nested() { String pkg = "com.google.example.examples.library.v1"; String name = "Charles"; Reference ref = @@ -69,7 +69,7 @@ public void basic_nested() { } @Test - public void basic_nestedAndStaticImport() { + void basic_nestedAndStaticImport() { String pkg = "com.google.example.examples.library.v1"; String name = "Charles"; String enclosingClassName = "Babbage"; @@ -89,7 +89,7 @@ public void basic_nestedAndStaticImport() { } @Test - public void concreteHierarchiesNotHandled() { + void concreteHierarchiesNotHandled() { String pkg = "java.io"; String name = "IOException"; Reference ref = VaporReference.builder().setName(name).setPakkage(pkg).build(); @@ -101,7 +101,7 @@ public void concreteHierarchiesNotHandled() { } @Test - public void enclosingClass() { + void enclosingClass() { String pkg = "java.util"; String enclosingName = "Map"; String name = "Entry"; diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableExprTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableExprTest.java index 43a5fd4f09..08dc046356 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableExprTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableExprTest.java @@ -19,11 +19,11 @@ import java.util.Arrays; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class VariableExprTest { +class VariableExprTest { @Test - public void validVariableExpr_basic() { + void validVariableExpr_basic() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); assertThat(variableExpr.variable()).isEqualTo(variable); @@ -35,7 +35,7 @@ public void validVariableExpr_basic() { } @Test - public void validVariableExpr_staticReference() { + void validVariableExpr_staticReference() { VariableExpr.builder() .setVariable(Variable.builder().setType(TypeNode.INT).setName("MAX_VALUE").build()) .setStaticReferenceType(TypeNode.INT_OBJECT) @@ -43,7 +43,7 @@ public void validVariableExpr_staticReference() { } @Test - public void validVariableExpr_classFieldOnStaticReference() { + void validVariableExpr_classFieldOnStaticReference() { VariableExpr.builder() .setVariable( Variable.builder() @@ -55,7 +55,7 @@ public void validVariableExpr_classFieldOnStaticReference() { } @Test - public void validVariableExpr_classFieldOnExprReference() { + void validVariableExpr_classFieldOnExprReference() { VariableExpr.builder() .setVariable( Variable.builder() @@ -71,7 +71,7 @@ public void validVariableExpr_classFieldOnExprReference() { } @Test - public void validVariableExpr_withFields() { + void validVariableExpr_withFields() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -89,7 +89,7 @@ public void validVariableExpr_withFields() { } @Test - public void validVariableExpr_declaration() { + void validVariableExpr_declaration() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -99,7 +99,7 @@ public void validVariableExpr_declaration() { } @Test - public void validVariableExpr_volatileDeclaration() { + void validVariableExpr_volatileDeclaration() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -118,7 +118,7 @@ public void validVariableExpr_volatileDeclaration() { } @Test - public void validVariableExpr_reference() { + void validVariableExpr_reference() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -128,7 +128,7 @@ public void validVariableExpr_reference() { } @Test - public void validVariableExpr_referenceWithModifiersSet() { + void validVariableExpr_referenceWithModifiersSet() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -144,7 +144,7 @@ public void validVariableExpr_referenceWithModifiersSet() { } @Test - public void validVariableExpr_templatedArgInMethod() { + void validVariableExpr_templatedArgInMethod() { Variable variable = Variable.builder() .setName("x") @@ -158,7 +158,7 @@ public void validVariableExpr_templatedArgInMethod() { } @Test - public void validVariableExpr_templatedArgNameAndTypeInMethod() { + void validVariableExpr_templatedArgNameAndTypeInMethod() { Variable variable = Variable.builder() .setName("x") @@ -174,7 +174,7 @@ public void validVariableExpr_templatedArgNameAndTypeInMethod() { } @Test - public void validVariableExpr_declarationWithAnnotations() { + void validVariableExpr_declarationWithAnnotations() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -194,7 +194,7 @@ public void validVariableExpr_declarationWithAnnotations() { } @Test - public void invalidVariableExpr_templatedArgInMethodHasNonStringNonTypeNodeObject() { + void invalidVariableExpr_templatedArgInMethodHasNonStringNonTypeNodeObject() { Variable variable = Variable.builder() .setName("x") @@ -210,7 +210,7 @@ public void invalidVariableExpr_templatedArgInMethodHasNonStringNonTypeNodeObjec } @Test - public void invalidVariableExpr_badTemplateName() { + void invalidVariableExpr_badTemplateName() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); assertThrows( IdentifierNode.InvalidIdentifierException.class, @@ -222,7 +222,7 @@ public void invalidVariableExpr_badTemplateName() { } @Test - public void invalidVariableExpr_referencePrimitiveType() { + void invalidVariableExpr_referencePrimitiveType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -237,7 +237,7 @@ public void invalidVariableExpr_referencePrimitiveType() { } @Test - public void invalidVariableExpr_referenceAndDecl() { + void invalidVariableExpr_referenceAndDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -253,7 +253,7 @@ public void invalidVariableExpr_referenceAndDecl() { } @Test - public void invalidVariableExpr_exprAndStaticReference() { + void invalidVariableExpr_exprAndStaticReference() { Variable refVariable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); assertThrows( IllegalStateException.class, @@ -266,7 +266,7 @@ public void invalidVariableExpr_exprAndStaticReference() { } @Test - public void invalidVariableExpr_primitiveStaticReference() { + void invalidVariableExpr_primitiveStaticReference() { assertThrows( IllegalStateException.class, () -> @@ -277,7 +277,7 @@ public void invalidVariableExpr_primitiveStaticReference() { } @Test - public void invalidVariableExpr_standaloneClassField() { + void invalidVariableExpr_standaloneClassField() { assertThrows( IllegalStateException.class, () -> @@ -291,7 +291,7 @@ public void invalidVariableExpr_standaloneClassField() { } @Test - public void invalidVariableExpr_classFieldOnPrimitiveType() { + void invalidVariableExpr_classFieldOnPrimitiveType() { assertThrows( IllegalStateException.class, () -> @@ -310,7 +310,7 @@ public void invalidVariableExpr_classFieldOnPrimitiveType() { } @Test - public void invalidVariableExpr_annotationNoDeclaration() { + void invalidVariableExpr_annotationNoDeclaration() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr.Builder variableExprBuilder = VariableExpr.builder() diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableTest.java index b11cfd0662..50a752f796 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/VariableTest.java @@ -19,11 +19,11 @@ import static org.junit.Assert.assertThrows; import com.google.api.generator.engine.ast.TypeNode.TypeKind; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class VariableTest { +class VariableTest { @Test - public void createVariable_basic() { + void createVariable_basic() { assertValidVariable(TypeKind.INT, "intVar"); assertValidVariable(TypeKind.BOOLEAN, "boolVar"); assertValidVariable(TypeKind.DOUBLE, "doubleVar"); @@ -33,7 +33,7 @@ public void createVariable_basic() { } @Test - public void createVariable_setIdentifier() { + void createVariable_setIdentifier() { IdentifierNode identifierNode = IdentifierNode.builder().setName("x").build(); Variable variable = Variable.builder() @@ -46,7 +46,7 @@ public void createVariable_setIdentifier() { } @Test - public void createVariable_invalidType() { + void createVariable_invalidType() { assertInvalidVariable(TypeNode.VOID); assertInvalidVariable(TypeNode.NULL); } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/WhileStatementTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/WhileStatementTest.java index ebaedc31ef..82127968c8 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/WhileStatementTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/ast/WhileStatementTest.java @@ -19,11 +19,11 @@ import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class WhileStatementTest { +class WhileStatementTest { @Test - public void validWhileStatement_simple() { + void validWhileStatement_simple() { WhileStatement whileStatement = WhileStatement.builder() .setConditionExpr(createConditionExpr("condition")) @@ -33,7 +33,7 @@ public void validWhileStatement_simple() { } @Test - public void validWhileStatement_booleanObjectCondition() { + void validWhileStatement_booleanObjectCondition() { // The condition expression type can be boolean or its boxed type. VariableExpr condExpr = VariableExpr.withVariable( @@ -47,7 +47,7 @@ public void validWhileStatement_booleanObjectCondition() { } @Test - public void validWhileStatement_nested() { + void validWhileStatement_nested() { WhileStatement nestedWhileStatement = WhileStatement.builder() .setConditionExpr(createConditionExpr("nestedCondition")) @@ -62,7 +62,7 @@ public void validWhileStatement_nested() { } @Test - public void invalidWhileStatement_emptyBody() { + void invalidWhileStatement_emptyBody() { assertThrows( IllegalStateException.class, () -> { diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/InvalidSymbolTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/InvalidSymbolTest.java index 7fb5b1d5a5..2e940c0cc0 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/InvalidSymbolTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/InvalidSymbolTest.java @@ -16,12 +16,12 @@ import static com.google.common.truth.Truth.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class InvalidSymbolTest { +class InvalidSymbolTest { @Test - public void invalidSymbolDetected() { + void invalidSymbolDetected() { assertThat(InvalidSymbol.containsInvalidSymbol("foo")).isFalse(); assertThat(InvalidSymbol.containsInvalidSymbol("foo`foo")).isTrue(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/KeywordTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/KeywordTest.java index ef5d87e587..cfda620d60 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/KeywordTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/KeywordTest.java @@ -16,11 +16,11 @@ import static com.google.common.truth.Truth.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class KeywordTest { +class KeywordTest { @Test - public void keywordDetected() { + void keywordDetected() { // Modifiers. assertThat(Keyword.isKeyword("static")).isTrue(); assertThat(Keyword.isKeyword("private")).isTrue(); @@ -47,32 +47,32 @@ public void keywordDetected() { } @Test - public void unescapedKeyword_shouldReturnItselfIfEmpty() { + void unescapedKeyword_shouldReturnItselfIfEmpty() { assertThat(Keyword.unescapeKeyword("")).isEqualTo(""); } @Test - public void unescapedKeyword_shouldReturnItselfIfDoesNotEndWithEscapeChar() { + void unescapedKeyword_shouldReturnItselfIfDoesNotEndWithEscapeChar() { assertThat(Keyword.unescapeKeyword("hello")).isEqualTo("hello"); } @Test - public void unescapedKeyword_shouldReturnItselfIfEndsWithEscapeCharButNotAKeyword() { + void unescapedKeyword_shouldReturnItselfIfEndsWithEscapeCharButNotAKeyword() { assertThat(Keyword.unescapeKeyword("important_")).isEqualTo("important_"); } @Test - public void unescapedKeyword_shouldUnescapeIfEndsWithEscapeCharAndAKeyword() { + void unescapedKeyword_shouldUnescapeIfEndsWithEscapeCharAndAKeyword() { assertThat(Keyword.unescapeKeyword("import_")).isEqualTo("import"); } @Test - public void escapeKeyword_shouldEscapeIfIsAKeyword() { + void escapeKeyword_shouldEscapeIfIsAKeyword() { assertThat(Keyword.escapeKeyword("final")).isEqualTo("final_"); } @Test - public void escapeKeyword_shouldNotEscapeIfIsNotAKeyword() { + void escapeKeyword_shouldNotEscapeIfIsNotAKeyword() { assertThat(Keyword.escapeKeyword("fantasy")).isEqualTo("fantasy"); } } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/LiteralTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/LiteralTest.java index 80b155045e..fe4ee22713 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/LiteralTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/LiteralTest.java @@ -16,17 +16,17 @@ import static com.google.common.truth.Truth.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class LiteralTest { +class LiteralTest { @Test - public void booleanDetected() { + void booleanDetected() { assertThat(Literal.isBooleanLiteral("True")).isFalse(); assertThat(Literal.isBooleanLiteral("true")).isTrue(); } @Test - public void nullLDetected() { + void nullLDetected() { assertThat(Literal.isNullLiteral("NULL")).isFalse(); assertThat(Literal.isNullLiteral("null")).isTrue(); assertThat(Literal.isNullLiteral("null_asdf")).isFalse(); @@ -34,7 +34,7 @@ public void nullLDetected() { } @Test - public void integerDetected() { + void integerDetected() { assertThat(Literal.isIntegerLiteral("a123")).isFalse(); assertThat(Literal.isIntegerLiteral("123")).isTrue(); assertThat(Literal.isIntegerLiteral("-123")).isTrue(); @@ -44,7 +44,7 @@ public void integerDetected() { } @Test - public void longDetected() { + void longDetected() { assertThat(Literal.isLongLiteral("123")).isTrue(); assertThat(Literal.isLongLiteral("123L")).isTrue(); assertThat(Literal.isLongLiteral("123l")).isTrue(); @@ -53,7 +53,7 @@ public void longDetected() { } @Test - public void floatDetected() { + void floatDetected() { assertThat(Literal.isFloatLiteral("123")).isTrue(); assertThat(Literal.isFloatLiteral("123f")).isTrue(); assertThat(Literal.isFloatLiteral("123.")).isFalse(); @@ -68,7 +68,7 @@ public void floatDetected() { } @Test - public void doubleDetected() { + void doubleDetected() { assertThat(Literal.isDoubleLiteral("123")).isTrue(); assertThat(Literal.isDoubleLiteral("0.01")).isTrue(); assertThat(Literal.isDoubleLiteral(".01")).isTrue(); @@ -86,7 +86,7 @@ public void doubleDetected() { } @Test - public void literalDetected() { + void literalDetected() { assertThat(Literal.isLiteral("False")).isFalse(); assertThat(Literal.isLiteral("asdf")).isFalse(); assertThat(Literal.isLiteral("asdf12345")).isFalse(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/OperatorTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/OperatorTest.java index 4e89227519..dfcdc5e3fe 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/OperatorTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/OperatorTest.java @@ -16,12 +16,12 @@ import static com.google.common.truth.Truth.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class OperatorTest { +class OperatorTest { @Test - public void operatorsDetected() { + void operatorsDetected() { assertThat(Operator.containsOperator("foo")).isFalse(); assertThat(Operator.containsOperator("foo+foo")).isTrue(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/SeparatorTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/SeparatorTest.java index 81f6c93f13..96e5bddd7d 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/SeparatorTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/lexicon/SeparatorTest.java @@ -16,11 +16,11 @@ import static com.google.common.truth.Truth.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SeparatorTest { +class SeparatorTest { @Test - public void separatorTest() { + void separatorTest() { assertThat(Separator.containsSeparator("foo")).isFalse(); assertThat(Separator.containsSeparator("foo.foo")).isTrue(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/ImportWriterVisitorTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/ImportWriterVisitorTest.java index 4977749e0e..08d00af14d 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/ImportWriterVisitorTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/ImportWriterVisitorTest.java @@ -71,22 +71,22 @@ import java.util.Map; import java.util.stream.LongStream; import javax.annotation.Generated; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ImportWriterVisitorTest { +class ImportWriterVisitorTest { private static final String CURRENT_PACKAGE = "com.google.api.generator.engine.foobar"; private static final String CURRENT_CLASS = "SomeClass"; private ImportWriterVisitor writerVisitor; - @Before - public void setUp() { + @BeforeEach + void setUp() { writerVisitor = new ImportWriterVisitor(); writerVisitor.initialize(CURRENT_PACKAGE, CURRENT_CLASS); } @Test - public void writeReferenceTypeImports_basic() { + void writeReferenceTypeImports_basic() { TypeNode.withReference(ConcreteReference.withClazz(List.class)).accept(writerVisitor); assertEquals("import java.util.List;\n\n", writerVisitor.write()); @@ -98,7 +98,7 @@ public void writeReferenceTypeImports_basic() { } @Test - public void writeReferenceTypeImports_useFullName() { + void writeReferenceTypeImports_useFullName() { TypeNode.withReference( ConcreteReference.builder().setClazz(List.class).setUseFullName(true).build()) .accept(writerVisitor); @@ -116,7 +116,7 @@ public void writeReferenceTypeImports_useFullName() { } @Test - public void writeNewObjectExprImports_basic() { + void writeNewObjectExprImports_basic() { // [Constructing] `new ArrayList<>()` NewObjectExpr newObjectExpr = NewObjectExpr.builder() @@ -128,7 +128,7 @@ public void writeNewObjectExprImports_basic() { } @Test - public void writeNewObjectExprImports_withArgs() { + void writeNewObjectExprImports_withArgs() { // [Constructing] `new FileOutputStream(File file)` and the argument needs to be imported. ConcreteReference fileOutputStreamRef = ConcreteReference.withClazz(FileOutputStream.class); ConcreteReference fileRef = ConcreteReference.withClazz(File.class); @@ -147,7 +147,7 @@ public void writeNewObjectExprImports_withArgs() { } @Test - public void writeNewObjectExprImports_genericsAndVariableArgs() { + void writeNewObjectExprImports_genericsAndVariableArgs() { // [Constructing] `new HashMap, Integer>>(int initialCapacity, float loadFactor)` ConcreteReference listRef = ConcreteReference.builder() @@ -179,7 +179,7 @@ public void writeNewObjectExprImports_genericsAndVariableArgs() { } @Test - public void writeNewObjectExprImports_methodExprArg() { + void writeNewObjectExprImports_methodExprArg() { // [Constructing] `new IOException(message, cause(mapArg))` and `cause(mapArg)` is a method // invocation with a `HashMap` argument. TypeNode exceptionType = TypeNode.withReference(ConcreteReference.withClazz(IOException.class)); @@ -208,7 +208,7 @@ public void writeNewObjectExprImports_methodExprArg() { } @Test - public void writeTernaryExprImports() { + void writeTernaryExprImports() { MethodInvocationExpr conditionExpr = MethodInvocationExpr.builder() .setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))) @@ -246,7 +246,7 @@ public void writeTernaryExprImports() { } @Test - public void writeVariableExprImports_staticReference() { + void writeVariableExprImports_staticReference() { VariableExpr variableExpr = VariableExpr.builder() .setVariable( @@ -268,7 +268,7 @@ public void writeVariableExprImports_staticReference() { } @Test - public void writeVariableExprImports_wildcardType() { + void writeVariableExprImports_wildcardType() { TypeNode wildcardListType = TypeNode.withReference( ConcreteReference.builder() @@ -286,7 +286,7 @@ public void writeVariableExprImports_wildcardType() { } @Test - public void writeVariableExprImport_wildcardTypeWithUpperBound() { + void writeVariableExprImport_wildcardTypeWithUpperBound() { TypeNode wildcardListType = TypeNode.withReference( ConcreteReference.builder() @@ -310,7 +310,7 @@ public void writeVariableExprImport_wildcardTypeWithUpperBound() { } @Test - public void writeVariableExprImports_reference() { + void writeVariableExprImports_reference() { Variable variable = Variable.builder() .setName("expr") @@ -334,7 +334,7 @@ public void writeVariableExprImports_reference() { } @Test - public void writeVariableExprImports_nestedReference() { + void writeVariableExprImports_nestedReference() { Variable variable = Variable.builder() .setName("expr") @@ -367,7 +367,7 @@ public void writeVariableExprImports_nestedReference() { } @Test - public void writeVariableExprImports_withAnnotations() { + void writeVariableExprImports_withAnnotations() { Variable variable = Variable.builder() .setName("expr") @@ -393,7 +393,7 @@ public void writeVariableExprImports_withAnnotations() { } @Test - public void writeVariableExprImports_annotationsWithDescription() { + void writeVariableExprImports_annotationsWithDescription() { Variable variable = Variable.builder() .setName("expr") @@ -430,7 +430,7 @@ public void writeVariableExprImports_annotationsWithDescription() { } @Test - public void writeVaporReferenceImport_outermostForNestedClass() { + void writeVaporReferenceImport_outermostForNestedClass() { VaporReference nestedVaporReference = VaporReference.builder() .setName("Inner") @@ -443,7 +443,7 @@ public void writeVaporReferenceImport_outermostForNestedClass() { } @Test - public void writeConcreteReferenceImport_outermostForNestedClass() { + void writeConcreteReferenceImport_outermostForNestedClass() { ConcreteReference nestedConcreteReference = ConcreteReference.withClazz(Outer.Middle.Inner.class); TypeNode.withReference(nestedConcreteReference).accept(writerVisitor); @@ -451,7 +451,7 @@ public void writeConcreteReferenceImport_outermostForNestedClass() { } @Test - public void writeAnonymousClassExprImports() { + void writeAnonymousClassExprImports() { // [Constructing] Function, MethodDefinition> ConcreteReference exceptionListRef = ConcreteReference.builder() @@ -526,7 +526,7 @@ public void writeAnonymousClassExprImports() { } @Test - public void writeThrowExprImports_basic() { + void writeThrowExprImports_basic() { TypeNode exceptionTypes = TypeNode.withReference(ConcreteReference.withClazz(IOException.class)); String message = "Some message asdf"; @@ -537,7 +537,7 @@ public void writeThrowExprImports_basic() { } @Test - public void writeThrowExprImports_throwExpr() { + void writeThrowExprImports_throwExpr() { Expr exprToThrow = MethodInvocationExpr.builder() .setStaticReferenceType( @@ -557,7 +557,7 @@ public void writeThrowExprImports_throwExpr() { } @Test - public void writeThrowExprImports_messageExpr() { + void writeThrowExprImports_messageExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); Expr messageExpr = MethodInvocationExpr.builder() @@ -584,7 +584,7 @@ public void writeThrowExprImports_messageExpr() { } @Test - public void writeThrowExprImports_messageAndCauseExpr() { + void writeThrowExprImports_messageAndCauseExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); Expr messageExpr = MethodInvocationExpr.builder() @@ -620,7 +620,7 @@ public void writeThrowExprImports_messageAndCauseExpr() { } @Test - public void writeInstanceofExprImports_basic() { + void writeInstanceofExprImports_basic() { TypeNode exprType = TypeNode.withReference(ConcreteReference.withClazz(Expr.class)); TypeNode assignExprType = TypeNode.withReference(ConcreteReference.withClazz(AssignmentExpr.class)); @@ -639,7 +639,7 @@ public void writeInstanceofExprImports_basic() { } @Test - public void writeEnumRefExprImports_basic() { + void writeEnumRefExprImports_basic() { TypeNode enumType = TypeNode.withReference( ConcreteReference.builder() @@ -655,7 +655,7 @@ public void writeEnumRefExprImports_basic() { } @Test - public void writeEnumRefExprImports_nested() { + void writeEnumRefExprImports_nested() { TypeNode enumType = TypeNode.withReference(ConcreteReference.withClazz(TypeNode.TypeKind.class)); EnumRefExpr enumRefExpr = EnumRefExpr.builder().setName("VOID").setType(enumType).build(); @@ -664,7 +664,7 @@ public void writeEnumRefExprImports_nested() { } @Test - public void writeReturnExprImports_basic() { + void writeReturnExprImports_basic() { ReturnExpr returnExpr = ReturnExpr.withExpr( MethodInvocationExpr.builder() @@ -676,7 +676,7 @@ public void writeReturnExprImports_basic() { } @Test - public void writeMethodDefinitionImports_templatedMixedNamesAndTypes() { + void writeMethodDefinitionImports_templatedMixedNamesAndTypes() { Reference mapRef = ConcreteReference.withClazz(Map.class); List arguments = Arrays.asList( @@ -718,7 +718,7 @@ public void writeMethodDefinitionImports_templatedMixedNamesAndTypes() { } @Test - public void writeReferenceConstructorExprImports_basic() { + void writeReferenceConstructorExprImports_basic() { VaporReference ref = VaporReference.builder().setName("Parent").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -729,7 +729,7 @@ public void writeReferenceConstructorExprImports_basic() { } @Test - public void writeReferenceConstructorExprImports_withArgs() { + void writeReferenceConstructorExprImports_withArgs() { VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -749,7 +749,7 @@ public void writeReferenceConstructorExprImports_withArgs() { } @Test - public void writeArithmeticOperationExprImports() { + void writeArithmeticOperationExprImports() { MethodInvocationExpr lhsExpr = MethodInvocationExpr.builder() .setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))) @@ -764,7 +764,7 @@ public void writeArithmeticOperationExprImports() { } @Test - public void writeSynchronizedStatementImports_basicThis() { + void writeSynchronizedStatementImports_basicThis() { SynchronizedStatement synchronizedStatement = SynchronizedStatement.builder() .setLock( @@ -786,7 +786,7 @@ public void writeSynchronizedStatementImports_basicThis() { } @Test - public void writeSuperObjectValueImports() { + void writeSuperObjectValueImports() { VaporReference ref = VaporReference.builder() .setName("Student") @@ -805,7 +805,7 @@ public void writeSuperObjectValueImports() { } @Test - public void writeSynchronizedStatementImports_basicVariableExpr() { + void writeSynchronizedStatementImports_basicVariableExpr() { VariableExpr strVarExpr = VariableExpr.withVariable( Variable.builder() @@ -833,7 +833,7 @@ public void writeSynchronizedStatementImports_basicVariableExpr() { } @Test - public void writeUnaryOperationExprImports_LogicalNot() { + void writeUnaryOperationExprImports_LogicalNot() { MethodInvocationExpr expr = MethodInvocationExpr.builder() .setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))) @@ -846,7 +846,7 @@ public void writeUnaryOperationExprImports_LogicalNot() { } @Test - public void writeUnaryOperationExprImports_PostIncrement() { + void writeUnaryOperationExprImports_PostIncrement() { MethodInvocationExpr expr = MethodInvocationExpr.builder() .setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))) @@ -859,7 +859,7 @@ public void writeUnaryOperationExprImports_PostIncrement() { } @Test - public void writeRelationalOperationExprImports() { + void writeRelationalOperationExprImports() { MethodInvocationExpr lhsExpr = MethodInvocationExpr.builder() .setStaticReferenceType(TypeNode.withReference(ConcreteReference.withClazz(Expr.class))) @@ -889,7 +889,7 @@ public void writeRelationalOperationExprImports() { } @Test - public void writeLogicalOperationExprImports() { + void writeLogicalOperationExprImports() { MethodInvocationExpr lhsExpr = MethodInvocationExpr.builder() .setStaticReferenceType( @@ -908,14 +908,14 @@ public void writeLogicalOperationExprImports() { } @Test - public void writeEmptyLineStatementImports() { + void writeEmptyLineStatementImports() { EmptyLineStatement statement = EmptyLineStatement.create(); statement.accept(writerVisitor); assertThat(writerVisitor.write()).isEmpty(); } @Test - public void writePackageInfoDefinitionImports() { + void writePackageInfoDefinitionImports() { PackageInfoDefinition packageInfo = PackageInfoDefinition.builder() .setPakkage("com.google.example.library.v1") @@ -935,7 +935,7 @@ public void writePackageInfoDefinitionImports() { } @Test - public void writeLambdaExprImports() { + void writeLambdaExprImports() { // Similar to method defnitions. Reference mapRef = ConcreteReference.withClazz(Map.class); List arguments = @@ -981,7 +981,7 @@ public void writeLambdaExprImports() { } @Test - public void importArrayExprTypes() { + void importArrayExprTypes() { ArrayExpr arrayExpr = ArrayExpr.builder() .setType( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java index e538b11cc7..d9a38d8d7f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java @@ -90,26 +90,26 @@ import java.util.Map; import java.util.concurrent.TimeoutException; import javax.annotation.Generated; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class JavaWriterVisitorTest { +class JavaWriterVisitorTest { private JavaWriterVisitor writerVisitor; - @Before - public void setUp() { + @BeforeEach + void setUp() { writerVisitor = new JavaWriterVisitor(); } @Test - public void writeIdentifier() { + void writeIdentifier() { String idName = "foobar"; IdentifierNode.builder().setName(idName).build().accept(writerVisitor); assertEquals(idName, writerVisitor.write()); } @Test - public void writePrimitiveType() { + void writePrimitiveType() { TypeNode intType = TypeNode.INT; assertThat(intType).isNotNull(); intType.accept(writerVisitor); @@ -117,7 +117,7 @@ public void writePrimitiveType() { } @Test - public void writePrimitiveArrayType() { + void writePrimitiveArrayType() { TypeNode byteArrayType = TypeNode.builder().setTypeKind(TypeNode.TypeKind.BYTE).setIsArray(true).build(); assertThat(byteArrayType).isNotNull(); @@ -126,7 +126,7 @@ public void writePrimitiveArrayType() { } @Test - public void writeReferenceType_basic() { + void writeReferenceType_basic() { TypeNode.withReference(ConcreteReference.withClazz(List.class)).accept(writerVisitor); assertEquals("List", writerVisitor.write()); @@ -138,7 +138,7 @@ public void writeReferenceType_basic() { } @Test - public void writeVaporReferenceType_nestedClasses() { + void writeVaporReferenceType_nestedClasses() { VaporReference nestedVaporReference = VaporReference.builder() .setName("Inner") @@ -150,7 +150,7 @@ public void writeVaporReferenceType_nestedClasses() { } @Test - public void writeConcreteReferenceType_nestedClasses() { + void writeConcreteReferenceType_nestedClasses() { ConcreteReference nestedConcreteReference = ConcreteReference.withClazz(Outer.Middle.Inner.class); TypeNode.withReference(nestedConcreteReference).accept(writerVisitor); @@ -158,7 +158,7 @@ public void writeConcreteReferenceType_nestedClasses() { } @Test - public void writeReferenceType_useFullName() { + void writeReferenceType_useFullName() { TypeNode.withReference( ConcreteReference.builder().setClazz(List.class).setUseFullName(true).build()) .accept(writerVisitor); @@ -176,21 +176,21 @@ public void writeReferenceType_useFullName() { } @Test - public void writeAnnotation_simple() { + void writeAnnotation_simple() { AnnotationNode annotation = AnnotationNode.OVERRIDE; annotation.accept(writerVisitor); assertEquals("@Override\n", writerVisitor.write()); } @Test - public void writeAnnotation_withStringDescription() { + void writeAnnotation_withStringDescription() { AnnotationNode annotation = AnnotationNode.withSuppressWarnings("all"); annotation.accept(writerVisitor); assertEquals("@SuppressWarnings(\"all\")\n", writerVisitor.write()); } @Test - public void writeAnnotation_withValueDescription() { + void writeAnnotation_withValueDescription() { TypeNode fakeAnnotationType = TypeNode.withReference( VaporReference.builder().setName("FakeAnnotation").setPakkage("com.foo.bar").build()); @@ -206,7 +206,7 @@ public void writeAnnotation_withValueDescription() { } @Test - public void writeAnnotation_withVariableExprDescription() { + void writeAnnotation_withVariableExprDescription() { TypeNode conditionalOnPropertyType = TypeNode.withReference( VaporReference.builder() @@ -235,7 +235,7 @@ public void writeAnnotation_withVariableExprDescription() { } @Test - public void writeAnnotation_withMultipleNamedDescriptions() { + void writeAnnotation_withMultipleNamedDescriptions() { TypeNode conditionalOnPropertyType = TypeNode.withReference( VaporReference.builder() @@ -274,7 +274,7 @@ public void writeAnnotation_withMultipleNamedDescriptions() { } @Test - public void writeAnnotation_withInvalidDescriptions() { + void writeAnnotation_withInvalidDescriptions() { TypeNode fakeAnnotationType = TypeNode.withReference( VaporReference.builder().setName("FakeAnnotation").setPakkage("com.foo.bar").build()); @@ -339,7 +339,7 @@ public void writeAnnotation_withInvalidDescriptions() { } @Test - public void writeAnnotation_withArrayExpr() { + void writeAnnotation_withArrayExpr() { TypeNode fakeAnnotationType = TypeNode.withReference( VaporReference.builder().setName("FakeAnnotation").setPakkage("com.foo.bar").build()); @@ -358,7 +358,7 @@ public void writeAnnotation_withArrayExpr() { } @Test - public void writeAnnotation_withArrayExprAssignment() { + void writeAnnotation_withArrayExprAssignment() { TypeNode fakeAnnotationType = TypeNode.withReference( VaporReference.builder().setName("FakeAnnotation").setPakkage("com.foo.bar").build()); @@ -404,7 +404,7 @@ public void writeAnnotation_withArrayExprAssignment() { } @Test - public void writeArrayExpr_add1StringExpr() { + void writeArrayExpr_add1StringExpr() { ArrayExpr expr = ArrayExpr.builder() .setType(TypeNode.createArrayTypeOf(TypeNode.STRING)) @@ -415,7 +415,7 @@ public void writeArrayExpr_add1StringExpr() { } @Test - public void writeArrayExpr_addManyStrExpr() { + void writeArrayExpr_addManyStrExpr() { ArrayExpr expr = ArrayExpr.builder() .setType(TypeNode.createArrayTypeOf(TypeNode.STRING)) @@ -428,7 +428,7 @@ public void writeArrayExpr_addManyStrExpr() { } @Test - public void writeArrayExpr_addManyClassExpr() { + void writeArrayExpr_addManyClassExpr() { ArrayExpr expr = ArrayExpr.builder() .setType(TypeNode.createArrayTypeOf(TypeNode.CLASS_OBJECT)) @@ -441,7 +441,7 @@ public void writeArrayExpr_addManyClassExpr() { } @Test - public void writeArrayExpr_mixedVariablesStaticAndNormalReference() { + void writeArrayExpr_mixedVariablesStaticAndNormalReference() { VariableExpr clazzVar = VariableExpr.builder() .setVariable( @@ -458,7 +458,7 @@ public void writeArrayExpr_mixedVariablesStaticAndNormalReference() { } @Test - public void writeArrayExpr_assignemntWithDeclaration() { + void writeArrayExpr_assignemntWithDeclaration() { VariableExpr varExpr = VariableExpr.builder() .setVariable( @@ -481,7 +481,7 @@ public void writeArrayExpr_assignemntWithDeclaration() { } @Test - public void writeNewObjectExpr_basic() { + void writeNewObjectExpr_basic() { // isGeneric() is true, but generics() is empty. ConcreteReference ref = ConcreteReference.withClazz(List.class); TypeNode type = TypeNode.withReference(ref); @@ -491,7 +491,7 @@ public void writeNewObjectExpr_basic() { } @Test - public void writeNewObjectExpr_withMethodExprArgs() { + void writeNewObjectExpr_withMethodExprArgs() { // isGeneric() is false, and generics() is empty. // [Constructing] `new IOException(message, cause())` and `cause()` is a method invocation. TypeNode type = TypeNode.withReference(ConcreteReference.withClazz(IOException.class)); @@ -512,7 +512,7 @@ public void writeNewObjectExpr_withMethodExprArgs() { } @Test - public void writeNewObjectExpr_withGenericsAndArgs() { + void writeNewObjectExpr_withGenericsAndArgs() { // isGeneric() is true and generics() is not empty. ConcreteReference listRef = ConcreteReference.builder() @@ -553,7 +553,7 @@ public void writeNewObjectExpr_withGenericsAndArgs() { /** =============================== EXPRESSIONS =============================== */ @Test - public void writeValueExpr() { + void writeValueExpr() { Value value = PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build(); ValueExpr valueExpr = ValueExpr.builder().setValue(value).build(); valueExpr.accept(writerVisitor); @@ -561,7 +561,7 @@ public void writeValueExpr() { } @Test - public void writeVariableExpr_basic() { + void writeVariableExpr_basic() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -570,7 +570,7 @@ public void writeVariableExpr_basic() { } @Test - public void writeVariableExpr_wildcardType() { + void writeVariableExpr_wildcardType() { TypeNode wildcardListType = TypeNode.withReference( ConcreteReference.builder() @@ -587,7 +587,7 @@ public void writeVariableExpr_wildcardType() { } @Test - public void writeVariableExpr_wildcardTypeWithUpperBound() { + void writeVariableExpr_wildcardTypeWithUpperBound() { TypeNode wildcardListType = TypeNode.withReference( ConcreteReference.builder() @@ -607,7 +607,7 @@ public void writeVariableExpr_wildcardTypeWithUpperBound() { } @Test - public void writeVariableExpr_staticReference() { + void writeVariableExpr_staticReference() { VariableExpr variableExpr = VariableExpr.builder() .setVariable( @@ -620,7 +620,7 @@ public void writeVariableExpr_staticReference() { } @Test - public void writeVariableExpr_nonDeclIgnoresModifiers() { + void writeVariableExpr_nonDeclIgnoresModifiers() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr expr = VariableExpr.builder() @@ -635,7 +635,7 @@ public void writeVariableExpr_nonDeclIgnoresModifiers() { } @Test - public void writeVariableExpr_basicLocalDecl() { + void writeVariableExpr_basicLocalDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr expr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -644,7 +644,7 @@ public void writeVariableExpr_basicLocalDecl() { } @Test - public void writeVariableExpr_localFinalDecl() { + void writeVariableExpr_localFinalDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr expr = @@ -655,7 +655,7 @@ public void writeVariableExpr_localFinalDecl() { } @Test - public void writeVariableExpr_scopedDecl() { + void writeVariableExpr_scopedDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr expr = VariableExpr.builder() @@ -669,7 +669,7 @@ public void writeVariableExpr_scopedDecl() { } @Test - public void writeVariableExpr_scopedStaticFinalDecl() { + void writeVariableExpr_scopedStaticFinalDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr expr = VariableExpr.builder() @@ -685,7 +685,7 @@ public void writeVariableExpr_scopedStaticFinalDecl() { } @Test - public void writeVariableExpr_scopedStaticFinalVolatileDecl() { + void writeVariableExpr_scopedStaticFinalVolatileDecl() { Variable variable = Variable.builder().setName("x").setType(TypeNode.BOOLEAN).build(); VariableExpr expr = VariableExpr.builder() @@ -702,7 +702,7 @@ public void writeVariableExpr_scopedStaticFinalVolatileDecl() { } @Test - public void writeVariableExpr_basicReference() { + void writeVariableExpr_basicReference() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -714,7 +714,7 @@ public void writeVariableExpr_basicReference() { } @Test - public void writeVariableExpr_basicReferenceWithModifiersSet() { + void writeVariableExpr_basicReferenceWithModifiersSet() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -732,7 +732,7 @@ public void writeVariableExpr_basicReferenceWithModifiersSet() { } @Test - public void writeVariableExpr_nestedReference() { + void writeVariableExpr_nestedReference() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING_ARRAY).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); @@ -751,7 +751,7 @@ public void writeVariableExpr_nestedReference() { } @Test - public void writeArithmeticOperationExpr_concatStringWithMethod() { + void writeArithmeticOperationExpr_concatStringWithMethod() { ValueExpr lhsExpr = ValueExpr.withValue(StringObjectValue.withValue("someWord")); MethodInvocationExpr methodInvocationExpr = MethodInvocationExpr.builder().setMethodName("getMethod").build(); @@ -768,7 +768,7 @@ public void writeArithmeticOperationExpr_concatStringWithMethod() { } @Test - public void writeArithmeticOperationExpr_concatStringWithNumber() { + void writeArithmeticOperationExpr_concatStringWithNumber() { ValueExpr rhsExpr = ValueExpr.withValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("5").build()); ValueExpr lhsExpr = ValueExpr.withValue(StringObjectValue.withValue("someWord")); @@ -780,7 +780,7 @@ public void writeArithmeticOperationExpr_concatStringWithNumber() { /** =============================== COMMENT =============================== */ @Test - public void writeBlockCommentStatement_basic() { + void writeBlockCommentStatement_basic() { String content = "this is a test comment"; BlockComment blockComment = BlockComment.builder().setComment(content).build(); CommentStatement commentStatement = CommentStatement.withComment(blockComment); @@ -790,7 +790,7 @@ public void writeBlockCommentStatement_basic() { } @Test - public void writeLineCommentStatement_basic() { + void writeLineCommentStatement_basic() { String content = "this is a test comment"; LineComment lineComment = LineComment.builder().setComment(content).build(); CommentStatement commentStatement = CommentStatement.withComment(lineComment); @@ -800,7 +800,7 @@ public void writeLineCommentStatement_basic() { } @Test - public void writeJavaDocCommentStatement_allComponents() { + void writeJavaDocCommentStatement_allComponents() { String content = "this is a test comment"; String deprecatedText = "Use the {@link ArchivedBookName} class instead."; String paramName = "shelfName"; @@ -861,7 +861,7 @@ public void writeJavaDocCommentStatement_allComponents() { } @Test - public void writeBlockComment_shortLines() { + void writeBlockComment_shortLines() { String content = "Apache License \nThis is a test file header"; BlockComment blockComment = BlockComment.builder().setComment(content).build(); String expected = @@ -871,7 +871,7 @@ public void writeBlockComment_shortLines() { } @Test - public void writeBlockComment_newLineInBetween() { + void writeBlockComment_newLineInBetween() { String content = "Apache License \n" + "Licensed under the Apache License, Version 2.0 (the \"License\");\n\n" @@ -890,7 +890,7 @@ public void writeBlockComment_newLineInBetween() { } @Test - public void writeLineComment_longLine() { + void writeLineComment_longLine() { String content = "this is a long test comment with so many words, hello world, hello again, hello for 3" + " times, blah, blah!"; @@ -905,7 +905,7 @@ public void writeLineComment_longLine() { } @Test - public void writeLineComment_specialChar() { + void writeLineComment_specialChar() { String content = "usage: gradle run -PmainClass=com.google.example.examples.library.v1.Hopper" + " [--args='[--shelf \"Novel\\\"`\b\t\n\r" @@ -923,7 +923,7 @@ public void writeLineComment_specialChar() { } @Test - public void writeJavaDocComment_specialChar() { + void writeJavaDocComment_specialChar() { // Only comments and sample codes in JavaDocComment need this escaper. //

    • are hard-coded in monolith generator, which do not need escaping. JavaDocComment javaDocComment = @@ -962,7 +962,7 @@ public void writeJavaDocComment_specialChar() { } @Test - public void writeFailingComment_specialChar() { + void writeFailingComment_specialChar() { JavaDocComment javaDocComment = JavaDocComment.builder() .addUnescapedComment( @@ -981,7 +981,7 @@ public void writeFailingComment_specialChar() { } @Test - public void writeTernaryExpr_basic() { + void writeTernaryExpr_basic() { Variable conditionVariable = Variable.builder().setName("condition").setType(TypeNode.BOOLEAN).build(); VariableExpr conditionExpr = VariableExpr.builder().setVariable(conditionVariable).build(); @@ -1002,7 +1002,7 @@ public void writeTernaryExpr_basic() { } @Test - public void writeAssignmentExpr_basicValue() { + void writeAssignmentExpr_basicValue() { Variable variable = Variable.builder().setName("x").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -1018,7 +1018,7 @@ public void writeAssignmentExpr_basicValue() { } @Test - public void writeAssignmentExpr_varToVar() { + void writeAssignmentExpr_varToVar() { Variable variable = Variable.builder().setName("foobar").setType(TypeNode.INT).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -1040,7 +1040,7 @@ public void writeAssignmentExpr_varToVar() { } @Test - public void writeAssignmentExpr_nullObjectValueReferenceType() { + void writeAssignmentExpr_nullObjectValueReferenceType() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -1056,7 +1056,7 @@ public void writeAssignmentExpr_nullObjectValueReferenceType() { } @Test - public void writeStringObjectValue_basic() { + void writeStringObjectValue_basic() { Value value = StringObjectValue.withValue("test"); Expr valueExpr = ValueExpr.builder().setValue(value).build(); valueExpr.accept(writerVisitor); @@ -1064,7 +1064,7 @@ public void writeStringObjectValue_basic() { } @Test - public void writeAssignmentExpr_stringObjectValue() { + void writeAssignmentExpr_stringObjectValue() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).setIsDecl(true).build(); @@ -1079,7 +1079,7 @@ public void writeAssignmentExpr_stringObjectValue() { } @Test - public void writeAssignmentExpr_variableDeclarationWithAnnotation() { + void writeAssignmentExpr_variableDeclarationWithAnnotation() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder() @@ -1098,7 +1098,7 @@ public void writeAssignmentExpr_variableDeclarationWithAnnotation() { } @Test - public void writeMethodInvocationExpr_basic() { + void writeMethodInvocationExpr_basic() { MethodInvocationExpr methodExpr = MethodInvocationExpr.builder().setMethodName("foobar").build(); @@ -1107,7 +1107,7 @@ public void writeMethodInvocationExpr_basic() { } @Test - public void writeMethodInvocationExpr_staticRef() { + void writeMethodInvocationExpr_staticRef() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -1126,7 +1126,7 @@ public void writeMethodInvocationExpr_staticRef() { } @Test - public void writeMethodInvocationExpr_genericWithArgs() { + void writeMethodInvocationExpr_genericWithArgs() { Reference mapReference = ConcreteReference.builder() .setClazz(HashMap.class) @@ -1173,7 +1173,7 @@ public void writeMethodInvocationExpr_genericWithArgs() { } @Test - public void writeMethodInvocationExpr_chained() { + void writeMethodInvocationExpr_chained() { Variable variable = Variable.builder().setType(TypeNode.INT).setName("libraryClient").build(); VariableExpr varExpr = VariableExpr.builder().setVariable(variable).build(); @@ -1199,7 +1199,7 @@ public void writeMethodInvocationExpr_chained() { } @Test - public void writeCastExpr_basic() { + void writeCastExpr_basic() { Variable variable = Variable.builder().setType(TypeNode.STRING).setName("str").build(); VariableExpr varExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr castExpr = @@ -1212,7 +1212,7 @@ public void writeCastExpr_basic() { } @Test - public void writeCastExpr_methodInvocation() { + void writeCastExpr_methodInvocation() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -1236,7 +1236,7 @@ public void writeCastExpr_methodInvocation() { } @Test - public void writeCastExpr_nested() { + void writeCastExpr_nested() { Variable variable = Variable.builder().setType(TypeNode.STRING).setName("str").build(); VariableExpr varExpr = VariableExpr.builder().setVariable(variable).build(); CastExpr castExpr = @@ -1250,7 +1250,7 @@ public void writeCastExpr_nested() { } @Test - public void writeAnonymousClassExpr_basic() { + void writeAnonymousClassExpr_basic() { ConcreteReference ref = ConcreteReference.withClazz(Runnable.class); TypeNode type = TypeNode.withReference(ref); AssignmentExpr assignmentExpr = createAssignmentExpr("foobar", "false", TypeNode.BOOLEAN); @@ -1277,7 +1277,7 @@ public void writeAnonymousClassExpr_basic() { } @Test - public void writeAnonymousClassExpr_withStatementsMethods() { + void writeAnonymousClassExpr_withStatementsMethods() { ConcreteReference ref = ConcreteReference.withClazz(Runnable.class); TypeNode type = TypeNode.withReference(ref); // [Constructing] private static final String s = "foo"; @@ -1322,7 +1322,7 @@ public void writeAnonymousClassExpr_withStatementsMethods() { } @Test - public void writeAnonymousClassExpr_generics() { + void writeAnonymousClassExpr_generics() { // [Constructing] Function, MethodDefinition> ConcreteReference exceptionListRef = ConcreteReference.builder() @@ -1378,7 +1378,7 @@ public void writeAnonymousClassExpr_generics() { } @Test - public void writeThrowExpr_basic() { + void writeThrowExpr_basic() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); ThrowExpr throwExpr = ThrowExpr.builder().setType(npeType).build(); @@ -1387,7 +1387,7 @@ public void writeThrowExpr_basic() { } @Test - public void writeThrowExpr_basicThrowExpr() { + void writeThrowExpr_basicThrowExpr() { Expr exprToThrow = MethodInvocationExpr.builder() .setStaticReferenceType( @@ -1402,7 +1402,7 @@ public void writeThrowExpr_basicThrowExpr() { } @Test - public void writeThrowExpr_basicWithMessage() { + void writeThrowExpr_basicWithMessage() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); String message = "Some message asdf"; @@ -1412,7 +1412,7 @@ public void writeThrowExpr_basicWithMessage() { } @Test - public void writeThrowExpr_basicWithCause() { + void writeThrowExpr_basicWithCause() { TypeNode npeType = TypeNode.withReference(ConcreteReference.withClazz(NullPointerException.class)); ThrowExpr throwExpr = @@ -1428,7 +1428,7 @@ public void writeThrowExpr_basicWithCause() { } @Test - public void writeThrowExpr_messageExpr() { + void writeThrowExpr_messageExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); Expr messageExpr = MethodInvocationExpr.builder() @@ -1442,7 +1442,7 @@ public void writeThrowExpr_messageExpr() { } @Test - public void writeThrowExpr_messageAndCauseExpr() { + void writeThrowExpr_messageAndCauseExpr() { TypeNode npeType = TypeNode.withExceptionClazz(NullPointerException.class); Expr messageExpr = MethodInvocationExpr.builder() @@ -1465,7 +1465,7 @@ public void writeThrowExpr_messageAndCauseExpr() { } @Test - public void writeInstanceofExpr() { + void writeInstanceofExpr() { Variable variable = Variable.builder().setName("x").setType(TypeNode.STRING).build(); VariableExpr variableExpr = VariableExpr.builder().setVariable(variable).build(); InstanceofExpr instanceofExpr = @@ -1475,7 +1475,7 @@ public void writeInstanceofExpr() { } @Test - public void writeEnumRefExpr_basic() { + void writeEnumRefExpr_basic() { TypeNode enumType = TypeNode.withReference( ConcreteReference.builder() @@ -1489,7 +1489,7 @@ public void writeEnumRefExpr_basic() { } @Test - public void writeEnumRefExpr_nested() { + void writeEnumRefExpr_nested() { TypeNode enumType = TypeNode.withReference(ConcreteReference.withClazz(TypeNode.TypeKind.class)); EnumRefExpr enumRefExpr = EnumRefExpr.builder().setName("VOID").setType(enumType).build(); @@ -1498,7 +1498,7 @@ public void writeEnumRefExpr_nested() { } @Test - public void writeReturnExpr_basic() { + void writeReturnExpr_basic() { ReturnExpr returnExpr = ReturnExpr.withExpr(ValueExpr.withValue(StringObjectValue.withValue("asdf"))); returnExpr.accept(writerVisitor); @@ -1507,7 +1507,7 @@ public void writeReturnExpr_basic() { /** =============================== STATEMENTS =============================== */ @Test - public void writeExprStatement() { + void writeExprStatement() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -1527,14 +1527,14 @@ public void writeExprStatement() { } @Test - public void writeBlockStatement_empty() { + void writeBlockStatement_empty() { BlockStatement blockStatement = BlockStatement.builder().build(); blockStatement.accept(writerVisitor); assertEquals("{\n}\n", writerVisitor.write()); } @Test - public void writeBlockStatement_simple() { + void writeBlockStatement_simple() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -1555,7 +1555,7 @@ public void writeBlockStatement_simple() { } @Test - public void writeBlockStatement_static() { + void writeBlockStatement_static() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -1581,7 +1581,7 @@ public void writeBlockStatement_static() { } @Test - public void writeIfStatement_simple() { + void writeIfStatement_simple() { AssignmentExpr assignExpr = createAssignmentExpr("x", "3", TypeNode.INT); Statement assignExprStatement = ExprStatement.withExpr(assignExpr); List ifBody = Arrays.asList(assignExprStatement, assignExprStatement); @@ -1597,7 +1597,7 @@ public void writeIfStatement_simple() { } @Test - public void writeIfStatement_withElse() { + void writeIfStatement_withElse() { AssignmentExpr assignExpr = createAssignmentExpr("x", "3", TypeNode.INT); Statement assignExprStatement = ExprStatement.withExpr(assignExpr); List ifBody = Arrays.asList(assignExprStatement, assignExprStatement); @@ -1625,7 +1625,7 @@ public void writeIfStatement_withElse() { } @Test - public void writeIfStatement_elseIfs() { + void writeIfStatement_elseIfs() { List ifBody = Arrays.asList( ExprStatement.withExpr(createAssignmentExpr("x", "3", TypeNode.INT)), @@ -1666,7 +1666,7 @@ public void writeIfStatement_elseIfs() { } @Test - public void writeIfStatement_nested() { + void writeIfStatement_nested() { List ifBody = Arrays.asList( ExprStatement.withExpr(createAssignmentExpr("x", "3", TypeNode.INT)), @@ -1729,7 +1729,7 @@ public void writeIfStatement_nested() { } @Test - public void writeWhileStatement_simple() { + void writeWhileStatement_simple() { AssignmentExpr assignExpr = createAssignmentExpr("x", "3", TypeNode.INT); Statement assignExprStatement = ExprStatement.withExpr(assignExpr); List whileBody = Arrays.asList(assignExprStatement, assignExprStatement); @@ -1745,7 +1745,7 @@ public void writeWhileStatement_simple() { } @Test - public void writeForStatement() { + void writeForStatement() { AssignmentExpr assignExpr = createAssignmentExpr("x", "3", TypeNode.INT); Statement assignExprStatement = ExprStatement.withExpr(assignExpr); List body = Arrays.asList(assignExprStatement, assignExprStatement); @@ -1769,7 +1769,7 @@ public void writeForStatement() { } @Test - public void writeGeneralForStatement_basicIsDecl() { + void writeGeneralForStatement_basicIsDecl() { AssignmentExpr assignExpr = createAssignmentExpr("x", "3", TypeNode.INT); Statement assignExprStatement = ExprStatement.withExpr(assignExpr); List body = Arrays.asList(assignExprStatement, assignExprStatement); @@ -1792,7 +1792,7 @@ public void writeGeneralForStatement_basicIsDecl() { } @Test - public void writeGeneralForStatement_basicIsNotDecl() { + void writeGeneralForStatement_basicIsNotDecl() { AssignmentExpr assignExpr = createAssignmentExpr("x", "3", TypeNode.INT); Statement assignExprStatement = ExprStatement.withExpr(assignExpr); List body = Arrays.asList(assignExprStatement, assignExprStatement); @@ -1814,7 +1814,7 @@ public void writeGeneralForStatement_basicIsNotDecl() { } @Test - public void writeTryCatchStatement_simple() { + void writeTryCatchStatement_simple() { Reference exceptionReference = ConcreteReference.withClazz(IllegalArgumentException.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = @@ -1836,7 +1836,7 @@ public void writeTryCatchStatement_simple() { } @Test - public void writeTryCatchStatement_simpleMultiCatch() { + void writeTryCatchStatement_simpleMultiCatch() { VariableExpr firstCatchVarExpr = VariableExpr.builder() .setVariable( @@ -1869,7 +1869,7 @@ public void writeTryCatchStatement_simpleMultiCatch() { } @Test - public void writeTryCatchStatement_simpleMultiCatchOrderMatters() { + void writeTryCatchStatement_simpleMultiCatchOrderMatters() { VariableExpr firstCatchVarExpr = VariableExpr.builder() .setVariable( @@ -1902,7 +1902,7 @@ public void writeTryCatchStatement_simpleMultiCatchOrderMatters() { } @Test - public void writeTryCatchStatement_withResources() { + void writeTryCatchStatement_withResources() { Reference exceptionReference = ConcreteReference.withClazz(IllegalArgumentException.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = @@ -1932,7 +1932,7 @@ public void writeTryCatchStatement_withResources() { } @Test - public void writeTryCatchStatement_sampleCodeNoCatch() { + void writeTryCatchStatement_sampleCodeNoCatch() { TryCatchStatement tryCatch = TryCatchStatement.builder() .setTryBody( @@ -1945,7 +1945,7 @@ public void writeTryCatchStatement_sampleCodeNoCatch() { } @Test - public void writeTryCatchStatement_sampleCodeWithCatch() { + void writeTryCatchStatement_sampleCodeWithCatch() { Reference exceptionReference = ConcreteReference.withClazz(IllegalArgumentException.class); TypeNode type = TypeNode.withReference(exceptionReference); VariableExpr variableExpr = @@ -1976,7 +1976,7 @@ public void writeTryCatchStatement_sampleCodeWithCatch() { } @Test - public void writeSynchronizedStatement_basicThis() { + void writeSynchronizedStatement_basicThis() { SynchronizedStatement synchronizedStatement = SynchronizedStatement.builder() .setLock( @@ -1993,7 +1993,7 @@ public void writeSynchronizedStatement_basicThis() { } @Test - public void writeSynchronizedStatement_basicVariableExpr() { + void writeSynchronizedStatement_basicVariableExpr() { VariableExpr strVarExpr = VariableExpr.withVariable( Variable.builder().setName("str").setType(TypeNode.STRING).build()); @@ -2012,7 +2012,7 @@ public void writeSynchronizedStatement_basicVariableExpr() { } @Test - public void writeMethodDefinition_basic() { + void writeMethodDefinition_basic() { MethodDefinition methodDefinition = MethodDefinition.builder() .setName("close") @@ -2029,7 +2029,7 @@ public void writeMethodDefinition_basic() { } @Test - public void writeMethodDefinition_constructor() { + void writeMethodDefinition_constructor() { TypeNode returnType = TypeNode.withReference( VaporReference.builder() @@ -2047,7 +2047,7 @@ public void writeMethodDefinition_constructor() { } @Test - public void writeMethodDefinition_basicEmptyBody() { + void writeMethodDefinition_basicEmptyBody() { MethodDefinition methodDefinition = MethodDefinition.builder() .setName("close") @@ -2060,7 +2060,7 @@ public void writeMethodDefinition_basicEmptyBody() { } @Test - public void writeMethodDefinition_basicAbstract() { + void writeMethodDefinition_basicAbstract() { MethodDefinition methodDefinition = MethodDefinition.builder() .setName("close") @@ -2078,7 +2078,7 @@ public void writeMethodDefinition_basicAbstract() { } @Test - public void writeMethodDefinition_basicAbstractEmptyBody() { + void writeMethodDefinition_basicAbstractEmptyBody() { MethodDefinition methodDefinition = MethodDefinition.builder() .setName("close") @@ -2092,7 +2092,7 @@ public void writeMethodDefinition_basicAbstractEmptyBody() { } @Test - public void writeMethodDefinition_withArgumentsAndReturnExpr() { + void writeMethodDefinition_withArgumentsAndReturnExpr() { ValueExpr returnExpr = ValueExpr.builder() .setValue(PrimitiveValue.builder().setType(TypeNode.INT).setValue("3").build()) @@ -2131,7 +2131,7 @@ public void writeMethodDefinition_withArgumentsAndReturnExpr() { } @Test - public void writeMethodDefinition_withCommentsAnnotationsAndThrows() { + void writeMethodDefinition_withCommentsAnnotationsAndThrows() { LineComment lineComment = LineComment.withComment("AUTO-GENERATED DOCUMENTATION AND METHOD"); JavaDocComment javaDocComment = JavaDocComment.builder() @@ -2208,7 +2208,7 @@ public void writeMethodDefinition_withCommentsAnnotationsAndThrows() { } @Test - public void writeMethodDefinition_templatedReturnTypeAndArguments() { + void writeMethodDefinition_templatedReturnTypeAndArguments() { Reference mapRef = ConcreteReference.withClazz(Map.class); List arguments = Arrays.asList( @@ -2249,7 +2249,7 @@ public void writeMethodDefinition_templatedReturnTypeAndArguments() { } @Test - public void writeClassDefinition_basicWithFileHeader() { + void writeClassDefinition_basicWithFileHeader() { List fileHeader = Arrays.asList(CommentStatement.withComment(BlockComment.withComment("Apache License"))); ClassDefinition classDef = @@ -2273,7 +2273,7 @@ public void writeClassDefinition_basicWithFileHeader() { } @Test - public void writeClassDefinition_withAnnotationsExtendsAndImplements() { + void writeClassDefinition_withAnnotationsExtendsAndImplements() { ClassDefinition classDef = ClassDefinition.builder() .setPackageString("com.google.example.library.v1.stub") @@ -2304,7 +2304,7 @@ public void writeClassDefinition_withAnnotationsExtendsAndImplements() { } @Test - public void writeClassDefinition_commentsStatementsAndMethods() { + void writeClassDefinition_commentsStatementsAndMethods() { LineComment lineComment = LineComment.withComment("AUTO-GENERATED DOCUMENTATION AND CLASS"); JavaDocComment javaDocComment = JavaDocComment.builder() @@ -2443,7 +2443,7 @@ public void writeClassDefinition_commentsStatementsAndMethods() { } @Test - public void writeClassDefinition_withImportCollision() { + void writeClassDefinition_withImportCollision() { VaporReference firstType = VaporReference.builder() @@ -2508,7 +2508,7 @@ public void writeClassDefinition_withImportCollision() { } @Test - public void writeReferenceConstructorExpr_thisConstructorWithArguments() { + void writeReferenceConstructorExpr_thisConstructorWithArguments() { VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -2530,7 +2530,7 @@ public void writeReferenceConstructorExpr_thisConstructorWithArguments() { } @Test - public void writeReferenceConstructorExpr_superConstructorWithNoArguments() { + void writeReferenceConstructorExpr_superConstructorWithNoArguments() { VaporReference ref = VaporReference.builder().setName("Parent").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -2541,7 +2541,7 @@ public void writeReferenceConstructorExpr_superConstructorWithNoArguments() { } @Test - public void writeThisObjectValue_methodReturn() { + void writeThisObjectValue_methodReturn() { VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -2560,7 +2560,7 @@ public void writeThisObjectValue_methodReturn() { } @Test - public void writeThisObjectValue_accessFieldAndInvokeMethod() { + void writeThisObjectValue_accessFieldAndInvokeMethod() { VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -2589,7 +2589,7 @@ public void writeThisObjectValue_accessFieldAndInvokeMethod() { } @Test - public void writeSuperObjectValue_accessFieldAndInvokeMethod() { + void writeSuperObjectValue_accessFieldAndInvokeMethod() { VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build(); TypeNode classType = TypeNode.withReference(ref); @@ -2619,7 +2619,7 @@ public void writeSuperObjectValue_accessFieldAndInvokeMethod() { } @Test - public void writeUnaryOperationExpr_postfixIncrement() { + void writeUnaryOperationExpr_postfixIncrement() { VariableExpr variableExpr = VariableExpr.withVariable(Variable.builder().setType(TypeNode.INT).setName("i").build()); UnaryOperationExpr postIncrementOperationExpr = @@ -2629,7 +2629,7 @@ public void writeUnaryOperationExpr_postfixIncrement() { } @Test - public void writeUnaryOperationExpr_logicalNot() { + void writeUnaryOperationExpr_logicalNot() { MethodInvocationExpr methodInvocationExpr = MethodInvocationExpr.builder() .setMethodName("isEmpty") @@ -2642,7 +2642,7 @@ public void writeUnaryOperationExpr_logicalNot() { } @Test - public void writeRelationalOperationExpr_equalTo() { + void writeRelationalOperationExpr_equalTo() { VariableExpr variableExprLHS = VariableExpr.withVariable( Variable.builder().setType(TypeNode.BOOLEAN_OBJECT).setName("isGood").build()); @@ -2659,7 +2659,7 @@ public void writeRelationalOperationExpr_equalTo() { } @Test - public void writeRelationOperationExpr_notEqualTo() { + void writeRelationOperationExpr_notEqualTo() { TypeNode someType = TypeNode.withReference( VaporReference.builder() @@ -2681,7 +2681,7 @@ public void writeRelationOperationExpr_notEqualTo() { } @Test - public void writeRelationalOperationExpr_lessThan() { + void writeRelationalOperationExpr_lessThan() { VariableExpr lhsExpr = VariableExpr.withVariable(createVariable("i", TypeNode.INT)); MethodInvocationExpr rhsExpr = MethodInvocationExpr.builder() @@ -2696,7 +2696,7 @@ public void writeRelationalOperationExpr_lessThan() { } @Test - public void writeLogicalOperationExpr_logicalAnd() { + void writeLogicalOperationExpr_logicalAnd() { VariableExpr lhsExpr = VariableExpr.withVariable(createVariable("isEmpty", TypeNode.BOOLEAN)); VaporReference ref = VaporReference.builder().setName("Student").setPakkage("com.google.example.v1").build(); @@ -2714,7 +2714,7 @@ public void writeLogicalOperationExpr_logicalAnd() { } @Test - public void writeLogicalOperationExpr_logicalOr() { + void writeLogicalOperationExpr_logicalOr() { VariableExpr lhsExpr = VariableExpr.withVariable(createVariable("isGood", TypeNode.BOOLEAN)); MethodInvocationExpr rhsExpr = MethodInvocationExpr.builder() @@ -2728,7 +2728,7 @@ public void writeLogicalOperationExpr_logicalOr() { } @Test - public void writeAssignmentOperationExpr_multiplyAssignment() { + void writeAssignmentOperationExpr_multiplyAssignment() { VariableExpr lhsExpr = createVariableExpr("h", TypeNode.INT); ValueExpr rhsExpr = ValueExpr.withValue( @@ -2740,7 +2740,7 @@ public void writeAssignmentOperationExpr_multiplyAssignment() { } @Test - public void writeAssignmentOperationExpr_xorAssignment() { + void writeAssignmentOperationExpr_xorAssignment() { VariableExpr lhsExpr = createVariableExpr("h", TypeNode.INT); TypeNode objectType = TypeNode.withReference( @@ -2761,7 +2761,7 @@ public void writeAssignmentOperationExpr_xorAssignment() { } @Test - public void writeLambdaExpr_noParameters() { + void writeLambdaExpr_noParameters() { LambdaExpr lambdaExpr = LambdaExpr.builder() .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue("foo"))) @@ -2771,7 +2771,7 @@ public void writeLambdaExpr_noParameters() { } @Test - public void writeLambdaExpr_assignToVariable() { + void writeLambdaExpr_assignToVariable() { LambdaExpr lambdaExpr = LambdaExpr.builder() .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue("foo"))) @@ -2788,7 +2788,7 @@ public void writeLambdaExpr_assignToVariable() { } @Test - public void writeLambdaExpr_oneParameter() { + void writeLambdaExpr_oneParameter() { VariableExpr argVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -2805,7 +2805,7 @@ public void writeLambdaExpr_oneParameter() { } @Test - public void writeLambdaExpr_severalParameters() { + void writeLambdaExpr_severalParameters() { VariableExpr argOneVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -2832,7 +2832,7 @@ public void writeLambdaExpr_severalParameters() { } @Test - public void writeLambdaExpr_body() { + void writeLambdaExpr_body() { VariableExpr argVarExpr = VariableExpr.builder() .setVariable(Variable.builder().setName("arg").setType(TypeNode.INT).build()) @@ -2864,21 +2864,21 @@ public void writeLambdaExpr_body() { } @Test - public void writeEmptyLineStatement() { + void writeEmptyLineStatement() { EmptyLineStatement statement = EmptyLineStatement.create(); statement.accept(writerVisitor); assertEquals("\n", writerVisitor.write()); } @Test - public void writeBreakStatement() { + void writeBreakStatement() { BreakStatement statement = BreakStatement.create(); statement.accept(writerVisitor); assertEquals("break;", writerVisitor.write()); } @Test - public void writePackageInfoDefinition() { + void writePackageInfoDefinition() { PackageInfoDefinition packageInfo = PackageInfoDefinition.builder() .setPakkage("com.google.example.library.v1") @@ -2910,7 +2910,7 @@ public void writePackageInfoDefinition() { /** =============================== GOLDEN TESTS =============================== */ @Test - public void writeSGrpcServiceClientWithNestedClassImport() { + void writeSGrpcServiceClientWithNestedClassImport() { GapicContext context = TestProtoLoader.instance().parseNestedMessage(); Service nestedService = context.services().get(0); GapicClass clazz = ServiceClientClassComposer.instance().generate(context, nestedService); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryPackageInfoComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryPackageInfoComposerTest.java index 92ee331448..df828d5119 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryPackageInfoComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryPackageInfoComposerTest.java @@ -22,13 +22,13 @@ import com.google.api.generator.test.protoloader.TestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ClientLibraryPackageInfoComposerTest { +class ClientLibraryPackageInfoComposerTest { private GapicContext context = TestProtoLoader.instance().parseShowcaseEcho(); @Test - public void composePackageInfo_showcase() { + void composePackageInfo_showcase() { GapicPackageInfo packageInfo = ClientLibraryPackageInfoComposer.generatePackageInfo(context); JavaWriterVisitor visitor = new JavaWriterVisitor(); packageInfo.packageInfo().accept(visitor); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryReflectConfigComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryReflectConfigComposerTest.java index 247cec9a85..715c7d5f7f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryReflectConfigComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ClientLibraryReflectConfigComposerTest.java @@ -26,9 +26,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ClientLibraryReflectConfigComposerTest { +class ClientLibraryReflectConfigComposerTest { private final Message.Builder testMessageBuilder = Message.builder() @@ -37,7 +37,7 @@ public class ClientLibraryReflectConfigComposerTest { .setType(TypeNode.OBJECT); @Test - public void composeReflectConfigs_showcase() { + void composeReflectConfigs_showcase() { final GapicContext context = TestProtoLoader.instance().parseShowcaseEcho(); List configs = Composer.composeNativeReflectConfig(context); assertThat(configs).isNotEmpty(); @@ -75,7 +75,7 @@ public void composeReflectConfigs_showcase() { } @Test - public void composeReflectConfigs_SimpleMessage() { + void composeReflectConfigs_SimpleMessage() { List entries = ClientLibraryReflectConfigComposer.calculateReflectConfigList( "foo.Bar", testMessageBuilder.build()); @@ -85,7 +85,7 @@ public void composeReflectConfigs_SimpleMessage() { } @Test - public void composeReflectConfigs_Enum() { + void composeReflectConfigs_Enum() { List entries = ClientLibraryReflectConfigComposer.calculateReflectConfigList( "e.Num", @@ -96,7 +96,7 @@ public void composeReflectConfigs_Enum() { } @Test - public void composeReflectConfigs_NestedEnums() { + void composeReflectConfigs_NestedEnums() { List nestedEnums = Arrays.asList("NestedEnum1", "NestedEnum2"); List entries = ClientLibraryReflectConfigComposer.calculateReflectConfigList( @@ -112,27 +112,27 @@ public void composeReflectConfigs_NestedEnums() { } @Test - public void formatNestedClassFullyQualifiedNames_noNested() { + void formatNestedClassFullyQualifiedNames_noNested() { assertEquals("a.B", ClientLibraryReflectConfigComposer.convertToBinaryName("a.B")); assertEquals("aa.bb.CC", ClientLibraryReflectConfigComposer.convertToBinaryName("aa.bb.CC")); } @Test - public void formatNestedClassFullyQualifiedNames_oneNested() { + void formatNestedClassFullyQualifiedNames_oneNested() { assertEquals("a.B$C", ClientLibraryReflectConfigComposer.convertToBinaryName("a.B.C")); assertEquals( "aa.bb.Cc$Dd", ClientLibraryReflectConfigComposer.convertToBinaryName("aa.bb.Cc.Dd")); } @Test - public void formatNestedClassFullyQualifiedNames_twoNested() { + void formatNestedClassFullyQualifiedNames_twoNested() { assertEquals("a.B$C$D", ClientLibraryReflectConfigComposer.convertToBinaryName("a.B.C.D")); assertEquals( "aa.bb.Cc$Dd$Ee", ClientLibraryReflectConfigComposer.convertToBinaryName("aa.bb.Cc.Dd.Ee")); } @Test - public void duplicateEntries_found() { + void duplicateEntries_found() { assertThat(ClientLibraryReflectConfigComposer.calculateDuplicates(Arrays.asList("a", "a", "b"))) .containsExactly("a"); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java index 66ad0584be..1d2053944f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java @@ -35,9 +35,9 @@ import java.nio.file.Paths; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ComposerTest { +class ComposerTest { private final GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseEcho(); private final Service echoProtoService = context.services().get(0); private final List clazzes = @@ -54,7 +54,7 @@ public class ComposerTest { private List ListofSamples = Arrays.asList(new Sample[] {sample}); @Test - public void gapicClass_addApacheLicense() { + void gapicClass_addApacheLicense() { ClassDefinition classDef = ClassDefinition.builder() .setPackageString("com.google.showcase.v1beta1.stub") @@ -74,7 +74,7 @@ public void gapicClass_addApacheLicense() { } @Test - public void composeSamples_showcase() { + void composeSamples_showcase() { GapicClass testClass = clazzes.get(0).withSamples(ListofSamples); List testClassList = Arrays.asList(new GapicClass[] {testClass}); @@ -96,7 +96,7 @@ public void composeSamples_showcase() { } @Test - public void gapicClass_addRegionTagAndHeaderToSample() { + void gapicClass_addRegionTagAndHeaderToSample() { Sample testSample; testSample = Composer.addRegionTagAndHeaderToSample(sample, "showcase", "v1"); assertEquals("Showcase", testSample.regionTag().apiShortName()); @@ -105,7 +105,7 @@ public void gapicClass_addRegionTagAndHeaderToSample() { } @Test - public void composeSamples_parseProtoPackage() { + void composeSamples_parseProtoPackage() { String defaultHost = "accessapproval.googleapis.com:443"; String protoPack = "google.cloud.accessapproval.v1"; diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposerTest.java index 77205f0122..44f3b49beb 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposerTest.java @@ -51,19 +51,19 @@ import com.google.common.collect.ImmutableMap; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class AbstractTransportServiceStubClassComposerTest { +class AbstractTransportServiceStubClassComposerTest { private JavaWriterVisitor writerVisitor; - @Before - public void setUp() { + @BeforeEach + void setUp() { writerVisitor = new JavaWriterVisitor(); } @Test - public void shouldGenerateRequestMutator_fieldConfiguredCorrectly() { + void shouldGenerateRequestMutator_fieldConfiguredCorrectly() { String ECHO_PACKAGE = "com.google.showcase.v1beta1"; List autoPopulatedFieldList = new ArrayList<>(); autoPopulatedFieldList.add("TestField"); @@ -105,7 +105,7 @@ public void shouldGenerateRequestMutator_fieldConfiguredCorrectly() { } @Test - public void shouldNotGenerateRequestMutator_fieldConfiguredIncorrectly() { + void shouldNotGenerateRequestMutator_fieldConfiguredIncorrectly() { String ECHO_PACKAGE = "com.google.showcase.v1beta1"; List autoPopulatedFieldList = new ArrayList<>(); autoPopulatedFieldList.add("TestField"); @@ -148,7 +148,7 @@ public void shouldNotGenerateRequestMutator_fieldConfiguredIncorrectly() { // TODO: add unit tests where the field is not found in the messageTypes map @Test - public void createAutoPopulatedRequestStatement_sampleField() { + void createAutoPopulatedRequestStatement_sampleField() { Reference RequestBuilderRef = VaporReference.builder() .setName("EchoRequest") @@ -194,7 +194,7 @@ public void createAutoPopulatedRequestStatement_sampleField() { } @Test - public void createRequestMutatorBody_TestField() { + void createRequestMutatorBody_TestField() { List bodyStatements = new ArrayList<>(); String ECHO_PACKAGE = "com.google.showcase.v1beta1"; List autoPopulatedFieldList = new ArrayList<>(); @@ -266,7 +266,7 @@ public void createRequestMutatorBody_TestField() { } @Test - public void createRequestMutatorBody_TestFieldNotString_shouldReturnNull() { + void createRequestMutatorBody_TestFieldNotString_shouldReturnNull() { List bodyStatements = new ArrayList<>(); String ECHO_PACKAGE = "com.google.showcase.v1beta1"; @@ -335,7 +335,7 @@ public void createRequestMutatorBody_TestFieldNotString_shouldReturnNull() { } @Test - public void createRequestMutatorBody_TestFieldFormatNotUUID_shouldReturnNull() { + void createRequestMutatorBody_TestFieldFormatNotUUID_shouldReturnNull() { List bodyStatements = new ArrayList<>(); String ECHO_PACKAGE = "com.google.showcase.v1beta1"; List autoPopulatedFieldList = new ArrayList<>(); @@ -403,7 +403,7 @@ public void createRequestMutatorBody_TestFieldFormatNotUUID_shouldReturnNull() { } @Test - public void createRequestMutatorBody_TestFieldIncorrectName_shouldReturnNull() { + void createRequestMutatorBody_TestFieldIncorrectName_shouldReturnNull() { List bodyStatements = new ArrayList<>(); String ECHO_PACKAGE = "com.google.showcase.v1beta1"; List autoPopulatedFieldList = new ArrayList<>(); @@ -471,7 +471,7 @@ public void createRequestMutatorBody_TestFieldIncorrectName_shouldReturnNull() { } @Test - public void createRequestMutator_TestField() { + void createRequestMutator_TestField() { String ECHO_PACKAGE = "com.google.showcase.v1beta1"; List autoPopulatedFieldList = new ArrayList<>(); autoPopulatedFieldList.add("TestField"); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/BatchingDescriptorComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/BatchingDescriptorComposerTest.java index e03ba5c641..ad13e0f45e 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/BatchingDescriptorComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/BatchingDescriptorComposerTest.java @@ -48,19 +48,19 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class BatchingDescriptorComposerTest { +class BatchingDescriptorComposerTest { private JavaWriterVisitor writerVisitor; - @Before - public void setUp() { + @BeforeEach + void setUp() { writerVisitor = new JavaWriterVisitor(); } @Test - public void batchingDescriptor_hasSubresponseField() { + void batchingDescriptor_hasSubresponseField() { FileDescriptor serviceFileDescriptor = PubsubProto.getDescriptor(); FileDescriptor commonResourcesFileDescriptor = CommonResources.getDescriptor(); ServiceDescriptor serviceDescriptor = serviceFileDescriptor.getServices().get(0); @@ -115,7 +115,7 @@ public void batchingDescriptor_hasSubresponseField() { } @Test - public void batchingDescriptor_noSubresponseField() { + void batchingDescriptor_noSubresponseField() { FileDescriptor serviceFileDescriptor = LoggingProto.getDescriptor(); ServiceDescriptor serviceDescriptor = serviceFileDescriptor.getServices().get(0); assertEquals(serviceDescriptor.getName(), "LoggingServiceV2"); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposerTest.java index 0d567f409d..717191842a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposerTest.java @@ -53,10 +53,10 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class RetrySettingsComposerTest { +class RetrySettingsComposerTest { private static final VariableExpr RETRY_PARAM_DEFINITIONS_VAR_EXPR = createRetryParamDefinitionsVarExpr(); private static final VariableExpr RETRY_CODES_DEFINITIONS_VAR_EXPR = @@ -64,13 +64,13 @@ public class RetrySettingsComposerTest { private JavaWriterVisitor writerVisitor; - @Before - public void setUp() { + @BeforeEach + void setUp() { writerVisitor = new JavaWriterVisitor(); } @Test - public void paramDefinitionsBlock_noConfigsFound() { + void paramDefinitionsBlock_noConfigsFound() { GapicContext context = TestProtoLoader.instance().parseShowcaseEcho(); Service service = context.services().get(0); @@ -98,7 +98,7 @@ public void paramDefinitionsBlock_noConfigsFound() { } @Test - public void paramDefinitionsBlock_basic() { + void paramDefinitionsBlock_basic() { GapicContext context = TestProtoLoader.instance().parseShowcaseEcho(); Service service = context.services().get(0); @@ -140,7 +140,7 @@ public void paramDefinitionsBlock_basic() { } @Test - public void codesDefinitionsBlock_noConfigsFound() { + void codesDefinitionsBlock_noConfigsFound() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); @@ -176,7 +176,7 @@ public void codesDefinitionsBlock_noConfigsFound() { } @Test - public void codesDefinitionsBlock_basic() { + void codesDefinitionsBlock_basic() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); @@ -215,7 +215,7 @@ public void codesDefinitionsBlock_basic() { } @Test - public void simpleBuilderExpr_basic() { + void simpleBuilderExpr_basic() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); @@ -296,7 +296,7 @@ public void simpleBuilderExpr_basic() { } @Test - public void lroBuilderExpr() { + void lroBuilderExpr() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); @@ -350,7 +350,7 @@ public void lroBuilderExpr() { } @Test - public void batchingSettings_minimalFlowControlSettings() { + void batchingSettings_minimalFlowControlSettings() { String filename = "pubsub_gapic.yaml"; Path path = Paths.get(TestProtoLoader.instance().getTestFilesDirectory(), filename); Optional> batchingSettingsOpt = @@ -404,7 +404,7 @@ public void batchingSettings_minimalFlowControlSettings() { } @Test - public void batchingSettings_fullFlowControlSettings() { + void batchingSettings_fullFlowControlSettings() { String filename = "logging_gapic.yaml"; Path path = Paths.get(TestProtoLoader.instance().getTestFilesDirectory(), filename); Optional> batchingSettingsOpt = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposerTest.java index 264060f474..04549457b8 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposerTest.java @@ -38,19 +38,19 @@ import java.util.Collections; import java.util.Map; import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class DefaultValueComposerTest { +class DefaultValueComposerTest { private JavaWriterVisitor writerVisitor; - @Before - public void setUp() { + @BeforeEach + void setUp() { writerVisitor = new JavaWriterVisitor(); } @Test - public void defaultValue_mapField() { + void defaultValue_mapField() { // Incorrect and will never happen in real usage, but proves that map detection is based on // isMap rather than type(). Field field = @@ -75,7 +75,7 @@ public void defaultValue_mapField() { } @Test - public void defaultValue_listField() { + void defaultValue_listField() { // Incorrect and will never happen in real usage, but proves that list detection is based on // isRepeated rather than type(). Field field = @@ -86,7 +86,7 @@ public void defaultValue_listField() { } @Test - public void defaultValue_enumField() { + void defaultValue_enumField() { // Incorrect and will never happen in real usage, but proves that enum detection is based on // isEnum() rather than type(). Field field = @@ -97,7 +97,7 @@ public void defaultValue_enumField() { } @Test - public void defaultValue_messageField() { + void defaultValue_messageField() { // Incorrect and will never happen in real usage, but proves that message detection is based on // isMessage() rather than type(). Field field = @@ -108,7 +108,7 @@ public void defaultValue_messageField() { } @Test - public void defaultValue_stringField() { + void defaultValue_stringField() { Field field = Field.builder().setName("foobar").setType(TypeNode.STRING).build(); Expr expr = DefaultValueComposer.createValue(field); expr.accept(writerVisitor); @@ -124,7 +124,7 @@ public void defaultValue_stringField() { } @Test - public void defaultValue_numericField() { + void defaultValue_numericField() { Field field = Field.builder().setName("foobar").setType(TypeNode.INT).build(); Expr expr = DefaultValueComposer.createValue(field); expr.accept(writerVisitor); @@ -138,7 +138,7 @@ public void defaultValue_numericField() { } @Test - public void defaultValue_booleanField() { + void defaultValue_booleanField() { Field field = Field.builder().setName("foobar").setType(TypeNode.BOOLEAN).build(); Expr expr = DefaultValueComposer.createValue(field); expr.accept(writerVisitor); @@ -146,7 +146,7 @@ public void defaultValue_booleanField() { } @Test - public void defaultValue_byteStringField() { + void defaultValue_byteStringField() { Field field = Field.builder() .setName("foobar") @@ -158,7 +158,7 @@ public void defaultValue_byteStringField() { } @Test - public void defaultValue_resourceNameWithOnePattern() { + void defaultValue_resourceNameWithOnePattern() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor); @@ -176,7 +176,7 @@ public void defaultValue_resourceNameWithOnePattern() { } @Test - public void defaultValue_resourceNameWithMultiplePatterns_noBindings() { + void defaultValue_resourceNameWithMultiplePatterns_noBindings() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor); @@ -201,7 +201,7 @@ public void defaultValue_resourceNameWithMultiplePatterns_noBindings() { } @Test - public void defaultValue_resourceNameWithMultiplePatterns_matchesBindings() { + void defaultValue_resourceNameWithMultiplePatterns_matchesBindings() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor); @@ -230,7 +230,7 @@ public void defaultValue_resourceNameWithMultiplePatterns_matchesBindings() { } @Test - public void defaultValue_resourceNameWithWildcardPattern() { + void defaultValue_resourceNameWithWildcardPattern() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor); @@ -248,7 +248,7 @@ public void defaultValue_resourceNameWithWildcardPattern() { } @Test - public void defaultValue_wildcardResourceNameWithOnlyDeletedTopic() { + void defaultValue_wildcardResourceNameWithOnlyDeletedTopic() { // Edge case that should never happen in practice. // Wildcard, but the resource names map has only other names that contain only the deleted-topic // constant. @@ -272,7 +272,7 @@ public void defaultValue_wildcardResourceNameWithOnlyDeletedTopic() { } @Test - public void defaultValue_resourceNameWithOnlyWildcards_valueOnly() { + void defaultValue_resourceNameWithOnlyWildcards_valueOnly() { // Edge case that occurs in GCS. // Wildcard, but the resource names map has only other names that contain only the deleted-topic // constant. @@ -296,7 +296,7 @@ public void defaultValue_resourceNameWithOnlyWildcards_valueOnly() { } @Test - public void defaultValue_resourceNameWithOnlyWildcards_matchingBinding() { + void defaultValue_resourceNameWithOnlyWildcards_matchingBinding() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor); @@ -334,7 +334,7 @@ public void defaultValue_resourceNameWithOnlyWildcards_matchingBinding() { } @Test - public void defaultValue_resourceNameWithOnlyWildcards_mismatchingBinding() { + void defaultValue_resourceNameWithOnlyWildcards_mismatchingBinding() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor); @@ -373,7 +373,7 @@ public void defaultValue_resourceNameWithOnlyWildcards_mismatchingBinding() { } @Test - public void defaultValue_resourceNameWithOnlyWildcards_allowAnonResourceNameClass() { + void defaultValue_resourceNameWithOnlyWildcards_allowAnonResourceNameClass() { // Edge case that occurs in GCS. // Wildcard, but the resource names map has only other names that contain only the deleted-topic // constant. @@ -412,7 +412,7 @@ public void defaultValue_resourceNameWithOnlyWildcards_allowAnonResourceNameClas } @Test - public void createSimpleMessageBuilderValue_resourceNameMultiplePatterns_matchesHttpBinding() { + void createSimpleMessageBuilderValue_resourceNameMultiplePatterns_matchesHttpBinding() { FileDescriptor messagingFileDescriptor = MessagingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(messagingFileDescriptor); Map typeStringsToResourceNames = @@ -446,8 +446,7 @@ Blurb Resource contains four patterns (in order of): } @Test - public void - createSimpleMessageBuilderValue_resourceNameMultiplePatterns_matchesAdditionalHttpBinding() { + void createSimpleMessageBuilderValue_resourceNameMultiplePatterns_matchesAdditionalHttpBinding() { FileDescriptor messagingFileDescriptor = MessagingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(messagingFileDescriptor); Map typeStringsToResourceNames = @@ -482,8 +481,7 @@ Blurb Resource contains four patterns (in order of): } @Test - public void - createSimpleMessageBuilderValue_resourceNameMultiplePatterns_doesNotMatchHttpBinding() { + void createSimpleMessageBuilderValue_resourceNameMultiplePatterns_doesNotMatchHttpBinding() { FileDescriptor messagingFileDescriptor = MessagingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(messagingFileDescriptor); Map typeStringsToResourceNames = @@ -518,7 +516,7 @@ Blurb Resource contains four patterns (in order of): } @Test - public void defaultValue_resourceNameMultiplePatterns_noHttpBinding() { + void defaultValue_resourceNameMultiplePatterns_noHttpBinding() { FileDescriptor messagingFileDescriptor = MessagingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(messagingFileDescriptor); Map typeStringsToResourceNames = @@ -537,7 +535,7 @@ public void defaultValue_resourceNameMultiplePatterns_noHttpBinding() { } @Test - public void createSimpleMessage_basicPrimitivesOnly() { + void createSimpleMessage_basicPrimitivesOnly() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map typeStringsToResourceNames = @@ -554,7 +552,7 @@ public void createSimpleMessage_basicPrimitivesOnly() { } @Test - public void createSimpleMessage_containsMessagesEnumsAndResourceName() { + void createSimpleMessage_containsMessagesEnumsAndResourceName() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map typeStringsToResourceNames = @@ -574,7 +572,7 @@ public void createSimpleMessage_containsMessagesEnumsAndResourceName() { } @Test - public void createSimpleMessage_valueField() { + void createSimpleMessage_valueField() { FileDescriptor echoFileDescriptor = com.google.showcase.grpcrest.v1beta1.EchoGrpcrest.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -596,7 +594,7 @@ public void createSimpleMessage_valueField() { } @Test - public void createSimpleMessage_containsRepeatedField() { + void createSimpleMessage_containsRepeatedField() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map typeStringsToResourceNames = @@ -613,7 +611,7 @@ public void createSimpleMessage_containsRepeatedField() { } @Test - public void createSimpleMessage_onlyOneofs() { + void createSimpleMessage_onlyOneofs() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map typeStringsToResourceNames = @@ -627,7 +625,7 @@ public void createSimpleMessage_onlyOneofs() { } @Test - public void createAnonymousResourceNameClass() { + void createAnonymousResourceNameClass() { Expr expr = DefaultValueComposer.createAnonymousResourceNameClassValue("resource", null); expr.accept(writerVisitor); String expected = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceCallableFactoryClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceCallableFactoryClassComposerTest.java index 66e00a0da9..6895bccf9e 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceCallableFactoryClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceCallableFactoryClassComposerTest.java @@ -19,11 +19,11 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GrpcServiceCallableFactoryClassComposerTest { +class GrpcServiceCallableFactoryClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = @@ -34,7 +34,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClasses_deprecated() { + void generateServiceClasses_deprecated() { GapicContext context = GrpcTestProtoLoader.instance().parseDeprecatedService(); Service protoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java index 1c00534433..3c2444411b 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java @@ -19,11 +19,11 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GrpcServiceStubClassComposerTest { +class GrpcServiceStubClassComposerTest { @Test - public void generateGrpcServiceStubClass_simple() { + void generateGrpcServiceStubClass_simple() { GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, echoProtoService); @@ -33,7 +33,7 @@ public void generateGrpcServiceStubClass_simple() { } @Test - public void generateGrpcServiceStubClass_deprecated() { + void generateGrpcServiceStubClass_deprecated() { GapicContext context = GrpcTestProtoLoader.instance().parseDeprecatedService(); Service protoService = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, protoService); @@ -43,7 +43,7 @@ public void generateGrpcServiceStubClass_deprecated() { } @Test - public void generateGrpcServiceStubClass_httpBindings() { + void generateGrpcServiceStubClass_httpBindings() { GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseTesting(); Service service = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service); @@ -53,7 +53,7 @@ public void generateGrpcServiceStubClass_httpBindings() { } @Test - public void generateGrpcServiceStubClass_routingHeaders() { + void generateGrpcServiceStubClass_routingHeaders() { GapicContext context = GrpcTestProtoLoader.instance().parseExplicitDynamicRoutingHeaderTesting(); Service service = context.services().get(0); @@ -64,7 +64,7 @@ public void generateGrpcServiceStubClass_routingHeaders() { } @Test - public void generateGrpcServiceStubClass_httpBindingsWithSubMessageFields() { + void generateGrpcServiceStubClass_httpBindingsWithSubMessageFields() { GapicContext context = GrpcTestProtoLoader.instance().parsePubSubPublisher(); Service service = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service); @@ -74,7 +74,7 @@ public void generateGrpcServiceStubClass_httpBindingsWithSubMessageFields() { } @Test - public void generateGrpcServiceStubClass_createBatchingCallable() { + void generateGrpcServiceStubClass_createBatchingCallable() { GapicContext context = GrpcTestProtoLoader.instance().parseLogging(); Service service = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service); @@ -84,7 +84,7 @@ public void generateGrpcServiceStubClass_createBatchingCallable() { } @Test - public void generateGrpcServiceStubClass_autopopulateField() { + void generateGrpcServiceStubClass_autopopulateField() { GapicContext context = GrpcTestProtoLoader.instance().parseAutoPopulateFieldTesting(); Service service = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceClassComposerTest.java index 7ef8dcf97e..1f6459e57c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceClassComposerTest.java @@ -19,30 +19,23 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class MockServiceClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - {"MockEcho", GrpcTestProtoLoader.instance().parseShowcaseEcho()}, - {"MockDeprecatedService", GrpcTestProtoLoader.instance().parseDeprecatedService()} - }); - } - - @Parameterized.Parameter public String name; +class MockServiceClassComposerTest { - @Parameterized.Parameter(1) - public GapicContext context; + static Stream data() { + return Stream.of( + Arguments.of("MockEcho", GrpcTestProtoLoader.instance().parseShowcaseEcho()), + Arguments.of( + "MockDeprecatedService", GrpcTestProtoLoader.instance().parseDeprecatedService())); + } - @Test - public void generateMockServiceClasses() { + @ParameterizedTest + @MethodSource("data") + void generateMockServiceClasses(String name, GapicContext context) { Service service = context.services().get(0); GapicClass clazz = MockServiceClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposerTest.java index f377c26e3c..547caeecb3 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposerTest.java @@ -19,30 +19,22 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class MockServiceImplClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - {"MockEchoImpl", GrpcTestProtoLoader.instance().parseShowcaseEcho()}, - {"MockDeprecatedServiceImpl", GrpcTestProtoLoader.instance().parseDeprecatedService()} - }); +class MockServiceImplClassComposerTest { + static Stream data() { + return Stream.of( + Arguments.of("MockEchoImpl", GrpcTestProtoLoader.instance().parseShowcaseEcho()), + Arguments.of( + "MockDeprecatedServiceImpl", GrpcTestProtoLoader.instance().parseDeprecatedService())); } - @Parameterized.Parameter public String name; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Test - public void generateMockServiceImplClasses() { + @ParameterizedTest + @MethodSource("data") + void generateMockServiceImplClasses(String name, GapicContext context) { Service service = context.services().get(0); GapicClass clazz = MockServiceImplClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java index 151ccb578d..7df2fc017c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java @@ -20,62 +20,49 @@ import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; import java.util.*; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ServiceClientClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - { +class ServiceClientClassComposerTest { + + private static Stream data() { + return Stream.of( + Arguments.of( "EchoClient", GrpcTestProtoLoader.instance().parseShowcaseEcho(), "localhost:7469", - "v1beta1" - }, - { + "v1beta1"), + Arguments.of( "DeprecatedServiceClient", GrpcTestProtoLoader.instance().parseDeprecatedService(), "localhost:7469", - "v1" - }, - { + "v1"), + Arguments.of( "IdentityClient", GrpcTestProtoLoader.instance().parseShowcaseIdentity(), "localhost:7469", - "v1beta1" - }, - { + "v1beta1"), + Arguments.of( "BookshopClient", GrpcTestProtoLoader.instance().parseBookshopService(), "localhost:2665", - "v1beta1" - }, - { + "v1beta1"), + Arguments.of( "MessagingClient", GrpcTestProtoLoader.instance().parseShowcaseMessaging(), "localhost:7469", - "v1beta1" - }, - }); + "v1beta1")); } - @Parameterized.Parameter public String name; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Parameterized.Parameter(2) - public String apiShortNameExpected; - - @Parameterized.Parameter(3) - public String packageVersionExpected; - - @Test - public void generateServiceClientClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceClientClasses( + String name, + GapicContext context, + String apiShortNameExpected, + String packageVersionExpected) { Service service = context.services().get(0); GapicClass clazz = ServiceClientClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientTestClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientTestClassComposerTest.java index fc1cb2ee55..c20bf8bf56 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientTestClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientTestClassComposerTest.java @@ -19,40 +19,29 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ServiceClientTestClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - {"EchoClientTest", GrpcTestProtoLoader.instance().parseShowcaseEcho(), 0}, - { +class ServiceClientTestClassComposerTest { + + static Stream data() { + return Stream.of( + Arguments.of("EchoClientTest", GrpcTestProtoLoader.instance().parseShowcaseEcho(), 0), + Arguments.of( "DeprecatedServiceClientTest", GrpcTestProtoLoader.instance().parseDeprecatedService(), - 0 - }, - {"TestingClientTest", GrpcTestProtoLoader.instance().parseShowcaseTesting(), 0}, - {"SubscriberClientTest", GrpcTestProtoLoader.instance().parsePubSubPublisher(), 1}, - {"LoggingClientTest", GrpcTestProtoLoader.instance().parseLogging(), 0}, - }); + 0), + Arguments.of("TestingClientTest", GrpcTestProtoLoader.instance().parseShowcaseTesting(), 0), + Arguments.of( + "SubscriberClientTest", GrpcTestProtoLoader.instance().parsePubSubPublisher(), 1), + Arguments.of("LoggingClientTest", GrpcTestProtoLoader.instance().parseLogging(), 0)); } - @Parameterized.Parameter public String name; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Parameterized.Parameter(2) - public int serviceIndex; - - @Test - public void generateServiceClientTestClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceClientTestClasses(String name, GapicContext context, int serviceIndex) { Service echoProtoService = context.services().get(serviceIndex); GapicClass clazz = ServiceClientTestClassComposer.instance().generate(context, echoProtoService); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceSettingsClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceSettingsClassComposerTest.java index 7a955fecd3..90e0df1a2a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceSettingsClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceSettingsClassComposerTest.java @@ -19,46 +19,34 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.TestProtoLoader; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ServiceSettingsClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - { +class ServiceSettingsClassComposerTest { + + static Stream data() { + return Stream.of( + Arguments.of( "EchoSettings", TestProtoLoader.instance().parseShowcaseEcho(), "localhost:7469", - "v1beta1" - }, - { + "v1beta1"), + Arguments.of( "DeprecatedServiceSettings", TestProtoLoader.instance().parseDeprecatedService(), "localhost:7469", - "v1" - } - }); + "v1")); } - @Parameterized.Parameter public String name; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Parameterized.Parameter(2) - public String apiShortNameExpected; - - @Parameterized.Parameter(3) - public String packageVersionExpected; - - @Test - public void generateServiceSettingsClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceSettingsClasses( + String name, + GapicContext context, + String apiShortNameExpected, + String packageVersionExpected) { Service service = context.services().get(0); GapicClass clazz = ServiceSettingsClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubClassComposerTest.java index 8984c3550c..15317cab94 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubClassComposerTest.java @@ -19,36 +19,26 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.TestProtoLoader; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -public class ServiceStubClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - {"EchoStub", TestProtoLoader.instance().parseShowcaseEcho(), "", ""}, - {"DeprecatedServiceStub", TestProtoLoader.instance().parseDeprecatedService(), "", ""} - }); +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class ServiceStubClassComposerTest { + static Stream data() { + return Stream.of( + Arguments.of("EchoStub", TestProtoLoader.instance().parseShowcaseEcho(), "", ""), + Arguments.of( + "DeprecatedServiceStub", TestProtoLoader.instance().parseDeprecatedService(), "", "")); } - @Parameterized.Parameter public String name; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Parameterized.Parameter(2) - public String apiShortNameExpected; - - @Parameterized.Parameter(3) - public String packageVersionExpected; - - @Test - public void generateServiceStubClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceStubClasses( + String name, + GapicContext context, + String apiShortNameExpected, + String packageVersionExpected) { Service service = context.services().get(0); GapicClass clazz = ServiceStubClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubSettingsClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubSettingsClassComposerTest.java index bfce68a45a..203b9f3894 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubSettingsClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceStubSettingsClassComposerTest.java @@ -19,64 +19,48 @@ import com.google.api.generator.gapic.model.Service; import com.google.api.generator.test.framework.Assert; import com.google.api.generator.test.protoloader.GrpcTestProtoLoader; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ServiceStubSettingsClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - { +class ServiceStubSettingsClassComposerTest { + static Stream data() { + return Stream.of( + Arguments.of( "LoggingServiceV2StubSettings", GrpcTestProtoLoader.instance().parseLogging(), "logging", - "v2" - }, - { + "v2"), + Arguments.of( "PublisherStubSettings", GrpcTestProtoLoader.instance().parsePubSubPublisher(), "pubsub", - "v1" - }, - { + "v1"), + Arguments.of( "EchoStubSettings", GrpcTestProtoLoader.instance().parseShowcaseEcho(), "localhost:7469", - "v1beta1" - }, - { + "v1beta1"), + Arguments.of( "DeprecatedServiceStubSettings", GrpcTestProtoLoader.instance().parseDeprecatedService(), "localhost:7469", - "v1" - }, - { + "v1"), + Arguments.of( "ApiVersionTestingStubSettings", GrpcTestProtoLoader.instance().parseApiVersionTesting(), "localhost:7469", - "v1" - } - }); + "v1")); } - @Parameterized.Parameter public String name; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Parameterized.Parameter(2) - public String apiShortNameExpected; - - @Parameterized.Parameter(3) - public String packageVersionExpected; - - @Test - public void generateServiceStubSettingsClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceStubSettingsClasses( + String name, + GapicContext context, + String apiShortNameExpected, + String packageVersionExpected) { Service service = context.services().get(0); GapicClass clazz = ServiceStubSettingsClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceCallableFactoryClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceCallableFactoryClassComposerTest.java index 3896549231..376c7fd32c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceCallableFactoryClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceCallableFactoryClassComposerTest.java @@ -24,11 +24,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GrpcServiceCallableFactoryClassComposerTest { +class GrpcServiceCallableFactoryClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = @@ -44,7 +44,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceStubClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceStubClassComposerTest.java index 5056de88ee..62067343a7 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceStubClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/GrpcServiceStubClassComposerTest.java @@ -24,11 +24,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GrpcServiceStubClassComposerTest { +class GrpcServiceStubClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, echoProtoService); @@ -42,7 +42,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceCallableFactoryClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceCallableFactoryClassComposerTest.java index 2ab7a72170..a5ded2aaaa 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceCallableFactoryClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceCallableFactoryClassComposerTest.java @@ -26,11 +26,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HttpJsonServiceCallableFactoryClassComposerTest { +class HttpJsonServiceCallableFactoryClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = @@ -47,7 +47,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceClientTestClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceClientTestClassComposerTest.java index a2dfe0d98a..ec8334924f 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceClientTestClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceClientTestClassComposerTest.java @@ -25,11 +25,12 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +class HttpJsonServiceClientTestClassComposerTest { -public class HttpJsonServiceClientTestClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = @@ -45,7 +46,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceStubClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceStubClassComposerTest.java index 7a497ec3ac..8ed541475a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceStubClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/HttpJsonServiceStubClassComposerTest.java @@ -25,11 +25,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HttpJsonServiceStubClassComposerTest { +class HttpJsonServiceStubClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = @@ -44,7 +44,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java index 66e88d87af..8efc43118c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java @@ -23,11 +23,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceClientClassComposerTest { +class ServiceClientClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService); @@ -41,7 +41,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesEmpty() { + void generateServiceClassesEmpty() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(1); GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService); @@ -55,7 +55,7 @@ public void generateServiceClassesEmpty() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = ServiceClientClassComposer.instance().generate(context, wickedProtoService); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientTestClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientTestClassComposerTest.java index 1a1d463bce..b7164ce590 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientTestClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientTestClassComposerTest.java @@ -26,11 +26,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceClientTestClassComposerTest { +class ServiceClientTestClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = @@ -45,7 +45,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceSettingsClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceSettingsClassComposerTest.java index 3d9b7bf8f0..5ee96c0cfe 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceSettingsClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceSettingsClassComposerTest.java @@ -23,11 +23,11 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceSettingsClassComposerTest { +class ServiceSettingsClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = ServiceSettingsClassComposer.instance().generate(context, echoProtoService); @@ -41,7 +41,7 @@ public void generateServiceClasses() { } @Test - public void generateServiceClassesWicked() { + void generateServiceClassesWicked() { GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); Service wickedProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceStubSettingsClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceStubSettingsClassComposerTest.java index c9439d525f..160df81f1d 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceStubSettingsClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceStubSettingsClassComposerTest.java @@ -23,30 +23,23 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ServiceStubSettingsClassComposerTest { - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - {"EchoStubSettings.golden", GrpcRestTestProtoLoader.instance().parseShowcaseEcho()}, - {"WickedStubSettings.golden", GrpcRestTestProtoLoader.instance().parseShowcaseWicked()} - }); +class ServiceStubSettingsClassComposerTest { + static Stream data() { + return Stream.of( + Arguments.of( + "EchoStubSettings.golden", GrpcRestTestProtoLoader.instance().parseShowcaseEcho()), + Arguments.of( + "WickedStubSettings.golden", GrpcRestTestProtoLoader.instance().parseShowcaseWicked())); } - @Parameterized.Parameter public String goldenFileName; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Test - public void generateServiceClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceClasses(String goldenFileName, GapicContext context) { Service echoProtoService = context.services().get(0); GapicClass clazz = ServiceStubSettingsClassComposer.instance().generate(context, echoProtoService); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposerTest.java index fa471f0ed2..7438d53b01 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposerTest.java @@ -48,25 +48,25 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ResourceNameHelperClassComposerTest { +class ResourceNameHelperClassComposerTest { private final String COLLIDING_RESOURCE_NAME_KEY = "config.googleapis.com/Resource"; private ServiceDescriptor echoService; private FileDescriptor echoFileDescriptor; - @Before - public void setUp() { + @BeforeEach + void setUp() { echoFileDescriptor = EchoOuterClass.getDescriptor(); echoService = echoFileDescriptor.getServices().get(0); assertEquals(echoService.getName(), "Echo"); } @Test - public void getTokenSet_basic() { + void getTokenSet_basic() { List patterns = Arrays.asList( "projects/{project}/agent/sessions/{session}", @@ -80,7 +80,7 @@ public void getTokenSet_basic() { } @Test - public void concatToUpperSnakeCaseName_basic() { + void concatToUpperSnakeCaseName_basic() { assertEquals( "PROJECT_LOCATION_AUTOSCALING_POLICY", ResourceNameHelperClassComposer.concatToUpperSnakeCaseName( @@ -88,7 +88,7 @@ public void concatToUpperSnakeCaseName_basic() { } @Test - public void concatToUpperCamelCaseName_basic() { + void concatToUpperCamelCaseName_basic() { assertEquals( "ProjectLocationAutoscalingPolicy", ResourceNameHelperClassComposer.concatToUpperCamelCaseName( @@ -96,7 +96,7 @@ public void concatToUpperCamelCaseName_basic() { } @Test - public void generateResourceNameClass_echoFoobarMultiplePatterns() { + void generateResourceNameClass_echoFoobarMultiplePatterns() { Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Set outputResourceNames = new HashSet<>(); @@ -119,7 +119,7 @@ public void generateResourceNameClass_echoFoobarMultiplePatterns() { } @Test - public void generateResourceNameClass_loggingOnePatternMultipleVariables() { + void generateResourceNameClass_loggingOnePatternMultipleVariables() { FileDescriptor serviceFileDescriptor = LoggingConfigProto.getDescriptor(); ServiceDescriptor serviceDescriptor = serviceFileDescriptor.getServices().get(0); assertEquals(serviceDescriptor.getName(), "ConfigServiceV2"); @@ -166,7 +166,7 @@ public void generateResourceNameClass_loggingOnePatternMultipleVariables() { } @Test - public void generateResourceNameClass_testingSessionOnePattern() { + void generateResourceNameClass_testingSessionOnePattern() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals(testingService.getName(), "Testing"); @@ -193,7 +193,7 @@ public void generateResourceNameClass_testingSessionOnePattern() { } @Test - public void generateResourceNameClass_testingBlueprintPatternWithNonSlashSeparator() { + void generateResourceNameClass_testingBlueprintPatternWithNonSlashSeparator() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals(testingService.getName(), "Testing"); @@ -220,7 +220,7 @@ public void generateResourceNameClass_testingBlueprintPatternWithNonSlashSeparat } @Test - public void generateResourceNameClass_childSingleton() { + void generateResourceNameClass_childSingleton() { ResourceName agentResname = ResourceName.builder() .setVariableName("agent") @@ -245,7 +245,7 @@ public void generateResourceNameClass_childSingleton() { } @Test - public void generateResourceNameClass_resourceNameCollisionIsAvoided() { + void generateResourceNameClass_resourceNameCollisionIsAvoided() { ResourceName collidingResourceName = Parser.parseResourceNames(CollisionsOuterClass.getDescriptor()) .get(COLLIDING_RESOURCE_NAME_KEY); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameTokenizerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameTokenizerTest.java index b49e731db2..9a4c0a3c67 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameTokenizerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameTokenizerTest.java @@ -22,22 +22,22 @@ import com.google.showcase.v1beta1.EchoOuterClass; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ResourceNameTokenizerTest { +class ResourceNameTokenizerTest { private ServiceDescriptor echoService; private FileDescriptor echoFileDescriptor; - @Before - public void setUp() { + @BeforeEach + void setUp() { echoFileDescriptor = EchoOuterClass.getDescriptor(); echoService = echoFileDescriptor.getServices().get(0); assertEquals(echoService.getName(), "Echo"); } @Test - public void parseTokenHierarchy_basic() { + void parseTokenHierarchy_basic() { List patterns = Arrays.asList( "projects/{project}/locations/{location}/autoscalingPolicies/{autoscaling_policy}", @@ -52,7 +52,7 @@ public void parseTokenHierarchy_basic() { } @Test - public void parseTokenHierarchy_substringsInPattern() { + void parseTokenHierarchy_substringsInPattern() { List patterns = Arrays.asList( "customers/{customer}/customerExtensionSettings/{customer_extension_setting}"); @@ -62,7 +62,7 @@ public void parseTokenHierarchy_substringsInPattern() { } @Test - public void parseTokenHierarchy_wildcards() { + void parseTokenHierarchy_wildcards() { List patterns = Arrays.asList( "projects/{project}/metricDescriptors/{metric_descriptor=**}", @@ -76,7 +76,7 @@ public void parseTokenHierarchy_wildcards() { } @Test - public void parseTokenHierarchy_singletonCollection() { + void parseTokenHierarchy_singletonCollection() { List patterns = Arrays.asList( "projects/{project}/agent/sessions/{session}", @@ -89,7 +89,7 @@ public void parseTokenHierarchy_singletonCollection() { } @Test - public void parseTokenHierarchy_singletonCollectionAndNonSlashSeparators() { + void parseTokenHierarchy_singletonCollectionAndNonSlashSeparators() { List patterns = Arrays.asList( "users/{user}/profile/blurbs/legacy/{legacy_user}~{blurb}", @@ -110,7 +110,7 @@ public void parseTokenHierarchy_singletonCollectionAndNonSlashSeparators() { } @Test - public void parseTokenHierarchy_invalidPatterns() { + void parseTokenHierarchy_invalidPatterns() { List patterns = Arrays.asList( "projects/{project}/agent/sessions/{session}/anotherSingleton", diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceCallableFactoryClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceCallableFactoryClassComposerTest.java index a38773eed8..ee2d4da0af 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceCallableFactoryClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceCallableFactoryClassComposerTest.java @@ -23,11 +23,11 @@ import com.google.api.generator.test.protoloader.RestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HttpJsonServiceCallableFactoryClassComposerTest { +class HttpJsonServiceCallableFactoryClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = RestTestProtoLoader.instance().parseCompliance(); Service echoProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposerTest.java index d1231ebd4a..807ac621b0 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposerTest.java @@ -35,20 +35,20 @@ import java.nio.file.Paths; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class HttpJsonServiceStubClassComposerTest { +class HttpJsonServiceStubClassComposerTest { private HttpJsonServiceStubClassComposer composer; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { composer = HttpJsonServiceStubClassComposer.instance(); } @Test - public void generateComplianceServiceClasses() { + void generateComplianceServiceClasses() { GapicContext context = RestTestProtoLoader.instance().parseCompliance(); Service complianceProtoServices = context.services().get(0); GapicClass clazz = composer.generate(context, complianceProtoServices); @@ -63,7 +63,7 @@ public void generateComplianceServiceClasses() { } @Test - public void generateEchoServiceClasses() { + void generateEchoServiceClasses() { GapicContext context = RestTestProtoLoader.instance().parseEcho(); Service echoProtoService = context.services().get(0); GapicClass clazz = composer.generate(context, echoProtoService); @@ -77,8 +77,7 @@ public void generateEchoServiceClasses() { } @Test - public void - getBindingFieldMethodName_shouldReturnGetFieldListIfTheFieldIsInLastPositionAndIsRepeated() { + void getBindingFieldMethodName_shouldReturnGetFieldListIfTheFieldIsInLastPositionAndIsRepeated() { Field field = Field.builder() .setIsRepeated(true) @@ -92,8 +91,7 @@ public void generateEchoServiceClasses() { } @Test - public void - getBindingFieldMethodName_shouldReturnGetFieldValueIfTheFieldIsInLastPositionAndIsEnum() { + void getBindingFieldMethodName_shouldReturnGetFieldValueIfTheFieldIsInLastPositionAndIsEnum() { Field field = Field.builder().setIsEnum(true).setName("doesNotMatter").setType(TypeNode.OBJECT).build(); HttpBinding httpBinding = @@ -103,7 +101,7 @@ public void generateEchoServiceClasses() { } @Test - public void + void getBindingFieldMethodName_shouldReturnGetFieldIfTheFieldIsInLastPositionAndNotRepeatedOrEnum() { Field field = Field.builder().setName("doesNotMatter").setType(TypeNode.OBJECT).build(); HttpBinding httpBinding = @@ -113,7 +111,7 @@ public void generateEchoServiceClasses() { } @Test - public void getBindingFieldMethodName_shouldReturnGetFieldIfTheFieldIsNotInLastPosition() { + void getBindingFieldMethodName_shouldReturnGetFieldIfTheFieldIsNotInLastPosition() { Field field = Field.builder().setName("doesNotMatter").setType(TypeNode.OBJECT).build(); HttpBinding httpBinding = HttpBinding.builder().setField(field).setName("doesNotMatter").build(); @@ -122,7 +120,7 @@ public void getBindingFieldMethodName_shouldReturnGetFieldIfTheFieldIsNotInLastP } @Test - public void parseOperationsCustomHttpRules_shouldReturnMapIfContextContainsValidServiceYaml() { + void parseOperationsCustomHttpRules_shouldReturnMapIfContextContainsValidServiceYaml() { List httpRuleList = ImmutableList.of( HttpRule.newBuilder() @@ -152,7 +150,7 @@ public void parseOperationsCustomHttpRules_shouldReturnMapIfContextContainsValid } @Test - public void parseOperationsCustomHttpRules_shouldReturnEmptyMapIfContextHasInvalidServiceYaml() { + void parseOperationsCustomHttpRules_shouldReturnEmptyMapIfContextHasInvalidServiceYaml() { GapicContext contextNullServiceYaml = RestTestProtoLoader.instance().parseCompliance(); contextNullServiceYaml = contextNullServiceYaml.toBuilder().setServiceYamlProto(null).build(); Map httpRuleMapNull = @@ -171,7 +169,7 @@ public void parseOperationsCustomHttpRules_shouldReturnEmptyMapIfContextHasInval } @Test - public void testGetOperationsURIValueFromHttpRule() { + void testGetOperationsURIValueFromHttpRule() { HttpRule getHttpRule = HttpRule.newBuilder().setGet("Get").build(); Truth.assertThat(composer.getOperationsURIValueFromHttpRule(getHttpRule)).isEqualTo("Get"); HttpRule postHttpRule = HttpRule.newBuilder().setPost("Post").build(); @@ -198,7 +196,7 @@ public void testGetOperationsURIValueFromHttpRule() { } @Test - public void generateGrpcServiceStubClass_routingHeaders() { + void generateGrpcServiceStubClass_routingHeaders() { GapicContext context = RestTestProtoLoader.instance().parseExplicitDynamicRoutingHeaderTesting(); Service service = context.services().get(0); @@ -209,7 +207,7 @@ public void generateGrpcServiceStubClass_routingHeaders() { } @Test - public void generateHttpJsonServiceStubClass_autopopulateField() { + void generateHttpJsonServiceStubClass_autopopulateField() { GapicContext context = RestTestProtoLoader.instance().parseAutoPopulateFieldTesting(); Service service = context.services().get(0); GapicClass clazz = HttpJsonServiceStubClassComposer.instance().generate(context, service); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceClientTestClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceClientTestClassComposerTest.java index 43e26e1f6e..5e9b2e0df1 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceClientTestClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceClientTestClassComposerTest.java @@ -24,11 +24,11 @@ import com.google.api.generator.test.protoloader.RestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceClientTestClassComposerTest { +class ServiceClientTestClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = RestTestProtoLoader.instance().parseCompliance(); Service echoProtoService = context.services().get(0); GapicClass clazz = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceSettingsClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceSettingsClassComposerTest.java index 4304e80f7c..45d428bacc 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceSettingsClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceSettingsClassComposerTest.java @@ -23,11 +23,11 @@ import com.google.api.generator.test.protoloader.RestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceSettingsClassComposerTest { +class ServiceSettingsClassComposerTest { @Test - public void generateServiceClasses() { + void generateServiceClasses() { GapicContext context = RestTestProtoLoader.instance().parseCompliance(); Service echoProtoService = context.services().get(0); GapicClass clazz = ServiceSettingsClassComposer.instance().generate(context, echoProtoService); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceStubSettingsClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceStubSettingsClassComposerTest.java index d2ac3b813a..d10a2555d1 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceStubSettingsClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/ServiceStubSettingsClassComposerTest.java @@ -23,34 +23,25 @@ import com.google.api.generator.test.protoloader.RestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -public class ServiceStubSettingsClassComposerTest { - - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList( - new Object[][] { - {"ComplianceStubSettings.golden", RestTestProtoLoader.instance().parseCompliance()}, - { +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class ServiceStubSettingsClassComposerTest { + + static Stream data() { + return Stream.of( + Arguments.of( + "ComplianceStubSettings.golden", RestTestProtoLoader.instance().parseCompliance()), + Arguments.of( "HttpJsonApiVersionTestingStubSettings.golden", - RestTestProtoLoader.instance().parseApiVersionTesting() - } - }); + RestTestProtoLoader.instance().parseApiVersionTesting())); } - @Parameterized.Parameter public String goldenFileName; - - @Parameterized.Parameter(1) - public GapicContext context; - - @Test - public void generateServiceClasses() { + @ParameterizedTest + @MethodSource("data") + void generateServiceClasses(String goldenFileName, GapicContext context) { Service protoService = context.services().get(0); GapicClass clazz = ServiceStubSettingsClassComposer.instance().generate(context, protoService); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleBodyJavaFormatterTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleBodyJavaFormatterTest.java index af58e7a30c..bdeda049c3 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleBodyJavaFormatterTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleBodyJavaFormatterTest.java @@ -18,12 +18,12 @@ import static org.junit.Assert.assertThrows; import com.google.api.generator.test.utils.LineFormatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SampleBodyJavaFormatterTest { +class SampleBodyJavaFormatterTest { @Test - public void validFormatSampleCode_tryCatchStatement() { + void validFormatSampleCode_tryCatchStatement() { String samplecode = LineFormatter.lines("try(boolean condition = false){", "int x = 3;", "}"); String result = SampleBodyJavaFormatter.format(samplecode); String expected = @@ -32,7 +32,7 @@ public void validFormatSampleCode_tryCatchStatement() { } @Test - public void validFormatSampleCode_longLineStatement() { + void validFormatSampleCode_longLineStatement() { String sampleCode = "SubscriptionAdminSettings subscriptionAdminSettings = " + "SubscriptionAdminSettings.newBuilder().setEndpoint(myEndpoint).build();"; @@ -45,7 +45,7 @@ public void validFormatSampleCode_longLineStatement() { } @Test - public void validFormatSampleCode_longChainMethod() { + void validFormatSampleCode_longChainMethod() { String sampleCode = "echoSettingsBuilder.echoSettings().setRetrySettings(" + "echoSettingsBuilder.echoSettings().getRetrySettings().toBuilder()" @@ -66,7 +66,7 @@ public void validFormatSampleCode_longChainMethod() { } @Test - public void invalidFormatSampleCode_nonStatement() { + void invalidFormatSampleCode_nonStatement() { assertThrows( SampleBodyJavaFormatter.FormatException.class, () -> { diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleCodeWriterTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleCodeWriterTest.java index d11d414816..820fa739a1 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleCodeWriterTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleCodeWriterTest.java @@ -34,17 +34,17 @@ import java.util.Arrays; import java.util.List; import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class SampleCodeWriterTest { +class SampleCodeWriterTest { private static String packageName = "com.google.samples"; private static List testingSampleStatements; private static Sample testingSample; private static RegionTag regionTag; - @BeforeClass - public static void setUp() { + @BeforeAll + static void setUp() { TypeNode settingType = TypeNode.withReference(ConcreteReference.withClazz(ClientSettings.class)); Variable aVar = Variable.builder().setName("clientSettings").setType(settingType).build(); @@ -92,7 +92,7 @@ public static void setUp() { } @Test - public void writeSampleCodeStatements() { + void writeSampleCodeStatements() { String result = SampleCodeWriter.write(testingSampleStatements); String expected = "ClientSettings clientSettings = ClientSettings.newBuilder().build();\n" @@ -103,7 +103,7 @@ public void writeSampleCodeStatements() { } @Test - public void writeInlineSample() { + void writeInlineSample() { String result = SampleCodeWriter.writeInlineSample(testingSampleStatements); String expected = LineFormatter.lines( @@ -120,7 +120,7 @@ public void writeInlineSample() { } @Test - public void writeExecutableSample() { + void writeExecutableSample() { Sample sample = testingSample.withRegionTag(regionTag.withOverloadDisambiguation("ExecutableSample")); String result = SampleCodeWriter.writeExecutableSample(sample, packageName); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerTest.java index 35d636cd32..94e381dca8 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerTest.java @@ -36,15 +36,15 @@ import com.google.common.collect.ImmutableList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SampleComposerTest { +class SampleComposerTest { private final String packageName = "com.google.example"; private final RegionTag.Builder regionTag = RegionTag.builder().setApiShortName("apiName").setServiceName("echo"); @Test - public void createInlineSample() { + void createInlineSample() { List sampleBody = Arrays.asList(ExprStatement.withExpr(systemOutPrint("testing"))); String sampleResult = writeSample(SampleComposer.composeInlineSample(sampleBody)); String expected = @@ -60,7 +60,7 @@ public void createInlineSample() { } @Test - public void createExecutableSampleEmptyStatementSample() { + void createExecutableSampleEmptyStatementSample() { Sample sample = Sample.builder() .setRegionTag( @@ -96,7 +96,7 @@ public void createExecutableSampleEmptyStatementSample() { } @Test - public void createExecutableSampleMethodArgsNoVar() { + void createExecutableSampleMethodArgsNoVar() { Statement sampleBody = ExprStatement.withExpr(systemOutPrint("Testing CreateExecutableSampleMethodArgsNoVar")); Sample sample = @@ -136,7 +136,7 @@ public void createExecutableSampleMethodArgsNoVar() { } @Test - public void createExecutableSampleMethod() { + void createExecutableSampleMethod() { VariableExpr variableExpr = VariableExpr.builder() .setVariable(Variable.builder().setType(TypeNode.STRING).setName("content").build()) @@ -185,7 +185,7 @@ public void createExecutableSampleMethod() { } @Test - public void createExecutableSampleMethodMultipleStatements() { + void createExecutableSampleMethodMultipleStatements() { VariableExpr strVariableExpr = VariableExpr.builder() .setVariable(Variable.builder().setType(TypeNode.STRING).setName("content").build()) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerUtilTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerUtilTest.java index 05b86ddf1b..b020da6184 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerUtilTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SampleComposerUtilTest.java @@ -28,9 +28,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SampleComposerUtilTest { +class SampleComposerUtilTest { private static final String SHOWCASE_PACKAGE_NAME = "com.google.showcase.v1beta1"; TypeNode clientType = TypeNode.withReference( @@ -55,7 +55,7 @@ public class SampleComposerUtilTest { .build(); @Test - public void assignClientVariableWithCreateMethodExpr() { + void assignClientVariableWithCreateMethodExpr() { String result = SampleCodeWriter.write( SampleComposerUtil.assignClientVariableWithCreateMethodExpr(echoClientVariableExpr)); @@ -65,14 +65,14 @@ public void assignClientVariableWithCreateMethodExpr() { } @Test - public void createOverloadDisambiguation_noargs() { + void createOverloadDisambiguation_noargs() { String result = SampleComposerUtil.createOverloadDisambiguation(new ArrayList<>()); String expected = "Noargs"; assertEquals(expected, result); } @Test - public void createOverloadDisambiguation_sameargs() { + void createOverloadDisambiguation_sameargs() { List methodArgVarExprs = Collections.nCopies(5, stringVariableExpr); String result = SampleComposerUtil.createOverloadDisambiguation(methodArgVarExprs); @@ -81,7 +81,7 @@ public void createOverloadDisambiguation_sameargs() { } @Test - public void createOverloadDisambiguation_containsInt() { + void createOverloadDisambiguation_containsInt() { List methodArgVarExprs = Arrays.asList(echoClientVariableExpr, stringVariableExpr, intVariableExpr); @@ -91,7 +91,7 @@ public void createOverloadDisambiguation_containsInt() { } @Test - public void handleDuplicateSamples_actualDuplicates() { + void handleDuplicateSamples_actualDuplicates() { List samples = Collections.nCopies(5, echoClientSample); assertEquals(samples.size(), 5); @@ -101,7 +101,7 @@ public void handleDuplicateSamples_actualDuplicates() { } @Test - public void handleDuplicateSamples_distinctDuplicates() { + void handleDuplicateSamples_distinctDuplicates() { VariableExpr echoClientVariableExprDiffVarName = VariableExpr.withVariable( Variable.builder().setName("echoClient2").setType(clientType).build()); @@ -128,7 +128,7 @@ public void handleDuplicateSamples_distinctDuplicates() { } @Test - public void handleDuplicateSamples_notDuplicateName() { + void handleDuplicateSamples_notDuplicateName() { Sample echoClientSampleDiffRpcName = echoClientSample.withRegionTag( echoClientSample.regionTag().toBuilder().setRpcName("createB").build()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientCallableMethodSampleComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientCallableMethodSampleComposerTest.java index f063c50903..2b058aca7c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientCallableMethodSampleComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientCallableMethodSampleComposerTest.java @@ -31,9 +31,9 @@ import java.util.Collections; import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceClientCallableMethodSampleComposerTest { +class ServiceClientCallableMethodSampleComposerTest { private static final String SHOWCASE_PACKAGE_NAME = "com.google.showcase.v1beta1"; private static final String LRO_PACKAGE_NAME = "com.google.longrunning"; private static final String PROTO_PACKAGE_NAME = "com.google.protobuf"; @@ -51,7 +51,7 @@ public class ServiceClientCallableMethodSampleComposerTest { /*Testing composeLroCallableMethod*/ @Test - public void valid_composeLroCallableMethod_withReturnResponse() { + void valid_composeLroCallableMethod_withReturnResponse() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -122,7 +122,7 @@ public void valid_composeLroCallableMethod_withReturnResponse() { } @Test - public void valid_composeLroCallableMethod_withReturnVoid() { + void valid_composeLroCallableMethod_withReturnVoid() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -191,7 +191,7 @@ public void valid_composeLroCallableMethod_withReturnVoid() { /*Testing composePagedCallableMethod*/ @Test - public void valid_composePagedCallableMethod() { + void valid_composePagedCallableMethod() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -255,7 +255,7 @@ public void valid_composePagedCallableMethod() { } @Test - public void invalid_composePagedCallableMethod_inputTypeNotExistInMessage() { + void invalid_composePagedCallableMethod_inputTypeNotExistInMessage() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -303,7 +303,7 @@ public void invalid_composePagedCallableMethod_inputTypeNotExistInMessage() { } @Test - public void invalid_composePagedCallableMethod_noExistMethodResponse() { + void invalid_composePagedCallableMethod_noExistMethodResponse() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -351,7 +351,7 @@ public void invalid_composePagedCallableMethod_noExistMethodResponse() { } @Test - public void invalid_composePagedCallableMethod_noRepeatedResponse() { + void invalid_composePagedCallableMethod_noRepeatedResponse() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -414,7 +414,7 @@ public void invalid_composePagedCallableMethod_noRepeatedResponse() { /*Testing composeStreamCallableMethod*/ @Test - public void valid_composeStreamCallableMethod_serverStream() { + void valid_composeStreamCallableMethod_serverStream() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -472,7 +472,7 @@ public void valid_composeStreamCallableMethod_serverStream() { } @Test - public void invalid_composeStreamCallableMethod_serverStreamNotExistRequest() { + void invalid_composeStreamCallableMethod_serverStreamNotExistRequest() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -520,7 +520,7 @@ public void invalid_composeStreamCallableMethod_serverStreamNotExistRequest() { } @Test - public void valid_composeStreamCallableMethod_bidiStream() { + void valid_composeStreamCallableMethod_bidiStream() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -587,7 +587,7 @@ public void valid_composeStreamCallableMethod_bidiStream() { } @Test - public void invalid_composeStreamCallableMethod_bidiStreamNotExistRequest() { + void invalid_composeStreamCallableMethod_bidiStreamNotExistRequest() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -635,7 +635,7 @@ public void invalid_composeStreamCallableMethod_bidiStreamNotExistRequest() { } @Test - public void valid_composeStreamCallableMethod_clientStream() { + void valid_composeStreamCallableMethod_clientStream() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -716,7 +716,7 @@ public void valid_composeStreamCallableMethod_clientStream() { } @Test - public void invalid_composeStreamCallableMethod_clientStreamNotExistRequest() { + void invalid_composeStreamCallableMethod_clientStreamNotExistRequest() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -765,7 +765,7 @@ public void invalid_composeStreamCallableMethod_clientStreamNotExistRequest() { /*Testing composeRegularCallableMethod*/ @Test - public void valid_composeRegularCallableMethod_unaryRpc() { + void valid_composeRegularCallableMethod_unaryRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -824,7 +824,7 @@ public void valid_composeRegularCallableMethod_unaryRpc() { } @Test - public void valid_composeRegularCallableMethod_lroRpc() { + void valid_composeRegularCallableMethod_lroRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -894,7 +894,7 @@ public void valid_composeRegularCallableMethod_lroRpc() { } @Test - public void valid_composeRegularCallableMethod_lroRpcWithReturnVoid() { + void valid_composeRegularCallableMethod_lroRpcWithReturnVoid() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -961,7 +961,7 @@ public void valid_composeRegularCallableMethod_lroRpcWithReturnVoid() { } @Test - public void valid_composeRegularCallableMethod_pageRpc() { + void valid_composeRegularCallableMethod_pageRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -1032,7 +1032,7 @@ public void valid_composeRegularCallableMethod_pageRpc() { } @Test - public void invalid_composeRegularCallableMethod_noExistMethodRequest() { + void invalid_composeRegularCallableMethod_noExistMethodRequest() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -1075,7 +1075,7 @@ public void invalid_composeRegularCallableMethod_noExistMethodRequest() { } @Test - public void invalid_composeRegularCallableMethod_noExistMethodResponsePagedRpc() { + void invalid_composeRegularCallableMethod_noExistMethodResponsePagedRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -1123,7 +1123,7 @@ public void invalid_composeRegularCallableMethod_noExistMethodResponsePagedRpc() } @Test - public void invalid_composeRegularCallableMethod_noRepeatedResponsePagedRpc() { + void invalid_composeRegularCallableMethod_noRepeatedResponsePagedRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposerTest.java index bf33f30e26..fc551eb571 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposerTest.java @@ -38,9 +38,9 @@ import java.util.Optional; import java.util.Set; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceClientHeaderSampleComposerTest { +class ServiceClientHeaderSampleComposerTest { private static final String SHOWCASE_PACKAGE_NAME = "com.google.showcase.v1beta1"; private static final String LRO_PACKAGE_NAME = "com.google.longrunning"; private static final String PROTO_PACKAGE_NAME = "com.google.protobuf"; @@ -58,7 +58,7 @@ public class ServiceClientHeaderSampleComposerTest { /*Testing composeClassHeaderSample*/ @Test - public void composeClassHeaderSample_unaryRpc() { + void composeClassHeaderSample_unaryRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -86,7 +86,7 @@ public void composeClassHeaderSample_unaryRpc() { } @Test - public void composeClassHeaderSample_firstMethodIsNotUnaryRpc() { + void composeClassHeaderSample_firstMethodIsNotUnaryRpc() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -170,7 +170,7 @@ public void composeClassHeaderSample_firstMethodIsNotUnaryRpc() { } @Test - public void composeClassHeaderSample_firstMethodHasNoSignatures() { + void composeClassHeaderSample_firstMethodHasNoSignatures() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -232,7 +232,7 @@ public void composeClassHeaderSample_firstMethodHasNoSignatures() { } @Test - public void composeClassHeaderSample_firstMethodIsStream() { + void composeClassHeaderSample_firstMethodIsStream() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -291,7 +291,7 @@ public void composeClassHeaderSample_firstMethodIsStream() { /*Testing composeSetCredentialsSample*/ @Test - public void composeSetCredentialsSample() { + void composeSetCredentialsSample() { TypeNode clientType = TypeNode.withReference( VaporReference.builder() @@ -320,7 +320,7 @@ public void composeSetCredentialsSample() { /*Testing composeSetEndpointSample*/ @Test - public void composeSetEndpointSample() { + void composeSetEndpointSample() { TypeNode clientType = TypeNode.withReference( VaporReference.builder() @@ -347,7 +347,7 @@ public void composeSetEndpointSample() { /*Testing composeShowcaseMethodSample*/ @Test - public void valid_composeShowcaseMethodSample_pagedRpcWithMultipleMethodArguments() { + void valid_composeShowcaseMethodSample_pagedRpcWithMultipleMethodArguments() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -455,7 +455,7 @@ public void valid_composeShowcaseMethodSample_pagedRpcWithMultipleMethodArgument } @Test - public void valid_composeShowcaseMethodSample_pagedRpcWithNoMethodArguments() { + void valid_composeShowcaseMethodSample_pagedRpcWithNoMethodArguments() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -537,7 +537,7 @@ public void valid_composeShowcaseMethodSample_pagedRpcWithNoMethodArguments() { } @Test - public void invalid_composeShowcaseMethodSample_noMatchedRepeatedResponseTypeInPagedMethod() { + void invalid_composeShowcaseMethodSample_noMatchedRepeatedResponseTypeInPagedMethod() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -587,7 +587,7 @@ public void invalid_composeShowcaseMethodSample_noMatchedRepeatedResponseTypeInP } @Test - public void invalid_composeShowcaseMethodSample_noRepeatedResponseTypeInPagedMethod() { + void invalid_composeShowcaseMethodSample_noRepeatedResponseTypeInPagedMethod() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -659,7 +659,7 @@ public void invalid_composeShowcaseMethodSample_noRepeatedResponseTypeInPagedMet } @Test - public void valid_composeShowcaseMethodSample_lroUnaryRpcWithNoMethodArgument() { + void valid_composeShowcaseMethodSample_lroUnaryRpcWithNoMethodArgument() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -727,7 +727,7 @@ public void valid_composeShowcaseMethodSample_lroUnaryRpcWithNoMethodArgument() } @Test - public void valid_composeShowcaseMethodSample_lroRpcWithReturnResponseType() { + void valid_composeShowcaseMethodSample_lroRpcWithReturnResponseType() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -813,7 +813,7 @@ public void valid_composeShowcaseMethodSample_lroRpcWithReturnResponseType() { } @Test - public void valid_composeShowcaseMethodSample_lroRpcWithReturnVoid() { + void valid_composeShowcaseMethodSample_lroRpcWithReturnVoid() { Descriptors.FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientMethodSampleComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientMethodSampleComposerTest.java index 6ba7985b5d..d1b93a932a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientMethodSampleComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientMethodSampleComposerTest.java @@ -30,16 +30,16 @@ import java.util.Collections; import java.util.Map; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceClientMethodSampleComposerTest { +class ServiceClientMethodSampleComposerTest { private static final String SHOWCASE_PACKAGE_NAME = "com.google.showcase.v1beta1"; private static final String LRO_PACKAGE_NAME = "com.google.longrunning"; private static final String PROTO_PACKAGE_NAME = "com.google.protobuf"; private static final String PAGINATED_FIELD_NAME = "page_size"; @Test - public void valid_composeDefaultSample_isPagedMethod() { + void valid_composeDefaultSample_isPagedMethod() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -101,7 +101,7 @@ public void valid_composeDefaultSample_isPagedMethod() { } @Test - public void invalid_composeDefaultSample_isPagedMethod() { + void invalid_composeDefaultSample_isPagedMethod() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -150,7 +150,7 @@ public void invalid_composeDefaultSample_isPagedMethod() { } @Test - public void valid_composeDefaultSample_hasLroMethodWithReturnResponse() { + void valid_composeDefaultSample_hasLroMethodWithReturnResponse() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -216,7 +216,7 @@ public void valid_composeDefaultSample_hasLroMethodWithReturnResponse() { } @Test - public void valid_composeDefaultSample_hasLroMethodWithReturnVoid() { + void valid_composeDefaultSample_hasLroMethodWithReturnVoid() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -285,7 +285,7 @@ public void valid_composeDefaultSample_hasLroMethodWithReturnVoid() { } @Test - public void valid_composeDefaultSample_pureUnaryReturnVoid() { + void valid_composeDefaultSample_pureUnaryReturnVoid() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -344,7 +344,7 @@ public void valid_composeDefaultSample_pureUnaryReturnVoid() { } @Test - public void valid_composeDefaultSample_pureUnaryReturnResponse() { + void valid_composeDefaultSample_pureUnaryReturnResponse() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Map messageTypes = Parser.parseMessages(echoFileDescriptor); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposerTest.java index 00f319b0ce..6aa6d1f583 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposerTest.java @@ -21,11 +21,11 @@ import com.google.api.generator.gapic.model.Sample; import com.google.api.generator.test.utils.LineFormatter; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SettingsSampleComposerTest { +class SettingsSampleComposerTest { @Test - public void composeSettingsSample_noMethods() { + void composeSettingsSample_noMethods() { TypeNode classType = TypeNode.withReference( VaporReference.builder() @@ -40,7 +40,7 @@ public void composeSettingsSample_noMethods() { } @Test - public void composeSettingsSample_serviceSettingsClass() { + void composeSettingsSample_serviceSettingsClass() { TypeNode classType = TypeNode.withReference( VaporReference.builder() @@ -68,7 +68,7 @@ public void composeSettingsSample_serviceSettingsClass() { } @Test - public void composeSettingsSample_serviceStubClass() { + void composeSettingsSample_serviceStubClass() { TypeNode classType = TypeNode.withReference( VaporReference.builder() diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/CommentFormatterTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/CommentFormatterTest.java index 2b82963899..0ec26d26cf 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/CommentFormatterTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/CommentFormatterTest.java @@ -17,13 +17,13 @@ import static org.junit.Assert.assertEquals; import com.google.api.generator.test.utils.LineFormatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CommentFormatterTest { +class CommentFormatterTest { private static final String SERVICE_DESCRIPTION_HEADER_PATTERN = "Service Description: %s"; @Test - public void parseCommentWithItemizedList_paragraphContainsList() { + void parseCommentWithItemizedList_paragraphContainsList() { String protobufComment = LineFormatter.lines( "Service Name\n\n", @@ -43,7 +43,7 @@ public void parseCommentWithItemizedList_paragraphContainsList() { } @Test - public void parseCommentWithItemizedList_paragraphStartsWithList() { + void parseCommentWithItemizedList_paragraphStartsWithList() { String protobufComment = LineFormatter.lines( "Paragraphs starting with list items should still be parsed as list:\n\n", @@ -61,7 +61,7 @@ public void parseCommentWithItemizedList_paragraphStartsWithList() { } @Test - public void parseCommentWithPrefixPattern_addIfStartsWithParagraph() { + void parseCommentWithPrefixPattern_addIfStartsWithParagraph() { String protobufComment = LineFormatter.lines( "Service Name\n\n", @@ -83,7 +83,7 @@ public void parseCommentWithPrefixPattern_addIfStartsWithParagraph() { } @Test - public void parseCommentWithPrefixPattern_ignoreIfStartsWithList() { + void parseCommentWithPrefixPattern_ignoreIfStartsWithList() { String protobufComment = LineFormatter.lines(" * This is item one\n", " * This is item two"); String result = CommentFormatter.formatAsJavaDocComment( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java index c8f220f65e..9636ca0ea6 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java @@ -17,11 +17,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PackageCheckerTest { +class PackageCheckerTest { @Test - public void isGaApi_gaVersionPresent() { + void isGaApi_gaVersionPresent() { assertTrue(PackageChecker.isGaApi("com.google.cloud.dataproc.v1.services")); assertTrue(PackageChecker.isGaApi("com.google.cloud.v1.foobar.services")); assertTrue(PackageChecker.isGaApi("com.google.cloud.dataproc.v1")); @@ -34,7 +34,7 @@ public void isGaApi_gaVersionPresent() { } @Test - public void isGaApi_alphaBetaVersionPresent() { + void isGaApi_alphaBetaVersionPresent() { assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1beta1")); assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1alpha1")); assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1beta")); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/FieldTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/FieldTest.java index 89ba60eabd..44069555a8 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/FieldTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/FieldTest.java @@ -18,12 +18,12 @@ import com.google.api.FieldInfo.Format; import com.google.api.generator.engine.ast.TypeNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class FieldTest { +class FieldTest { @Test - public void shouldAutoPopulate() { + void shouldAutoPopulate() { Field FIELD = Field.builder() .setName("SampleField") @@ -36,7 +36,7 @@ public void shouldAutoPopulate() { } @Test - public void isRequired_shouldNotAutoPopulate() { + void isRequired_shouldNotAutoPopulate() { Field FIELD = Field.builder() .setName("SampleField") @@ -49,7 +49,7 @@ public void isRequired_shouldNotAutoPopulate() { } @Test - public void fieldInfoFormatNotUUID4_shouldNotAutoPopulate() { + void fieldInfoFormatNotUUID4_shouldNotAutoPopulate() { Field FIELD = Field.builder() .setName("SampleField") @@ -62,7 +62,7 @@ public void fieldInfoFormatNotUUID4_shouldNotAutoPopulate() { } @Test - public void typeNotString_shouldNotAutoPopulate() { + void typeNotString_shouldNotAutoPopulate() { Field FIELD = Field.builder() .setName("SampleField") diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/GapicServiceConfigTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/GapicServiceConfigTest.java index ca4cd84418..b42e7e9134 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/GapicServiceConfigTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/GapicServiceConfigTest.java @@ -34,15 +34,15 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GapicServiceConfigTest { +class GapicServiceConfigTest { private static final double EPSILON = 1e-4; private static final String TESTDATA_DIRECTORY = "src/test/resources/"; @Test - public void serviceConfig_noConfigsFound() { + void serviceConfig_noConfigsFound() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Service service = parseService(echoFileDescriptor); @@ -70,7 +70,7 @@ public void serviceConfig_noConfigsFound() { } @Test - public void serviceConfig_basic() { + void serviceConfig_basic() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Service service = parseService(echoFileDescriptor); @@ -124,7 +124,7 @@ public void serviceConfig_basic() { } @Test - public void serviceConfig_withBatchingSettings() { + void serviceConfig_withBatchingSettings() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Service service = parseService(echoFileDescriptor); @@ -197,7 +197,7 @@ public void serviceConfig_withBatchingSettings() { } @Test - public void serviceConfig_withLroRetrySettings() { + void serviceConfig_withLroRetrySettings() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); Service service = parseService(echoFileDescriptor); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/HttpBindingsTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/HttpBindingsTest.java index f8713e0564..7ca27d167c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/HttpBindingsTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/HttpBindingsTest.java @@ -17,28 +17,28 @@ import com.google.api.generator.engine.ast.TypeNode; import com.google.api.generator.gapic.model.HttpBindings.HttpBinding; import com.google.common.truth.Truth; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class HttpBindingsTest { +class HttpBindingsTest { - public Field.Builder fieldBuilder; - public HttpBinding.Builder httpBindingBuilder; + private Field.Builder fieldBuilder; + private HttpBinding.Builder httpBindingBuilder; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { fieldBuilder = Field.builder().setName("doesNotMatter").setType(TypeNode.OBJECT); httpBindingBuilder = HttpBinding.builder().setName("doesNotMatter"); } @Test - public void isOptional_shouldReturnFalseIfFieldIsNull() { + void isOptional_shouldReturnFalseIfFieldIsNull() { HttpBinding httpBinding = httpBindingBuilder.build(); Truth.assertThat(httpBinding.isOptional()).isFalse(); } @Test - public void isOptional_shouldReturnFalseIfFieldExistsAndIsOptionalIsFalse() { + void isOptional_shouldReturnFalseIfFieldExistsAndIsOptionalIsFalse() { HttpBinding httpBinding = httpBindingBuilder.setField(fieldBuilder.setIsProto3Optional(false).build()).build(); @@ -46,7 +46,7 @@ public void isOptional_shouldReturnFalseIfFieldExistsAndIsOptionalIsFalse() { } @Test - public void isOptional_shouldReturnTrueIfFieldExistsAndIsOptionalIsTue() { + void isOptional_shouldReturnTrueIfFieldExistsAndIsOptionalIsTue() { HttpBinding httpBinding = httpBindingBuilder.setField(fieldBuilder.setIsProto3Optional(true).build()).build(); @@ -54,13 +54,13 @@ public void isOptional_shouldReturnTrueIfFieldExistsAndIsOptionalIsTue() { } @Test - public void isRepeated_shouldReturnFalseIfFieldIsNull() { + void isRepeated_shouldReturnFalseIfFieldIsNull() { HttpBinding httpBinding = httpBindingBuilder.build(); Truth.assertThat(httpBinding.isRepeated()).isFalse(); } @Test - public void isRepeated_shouldReturnFalseIfFieldExistsAndIsRepeatedIsFalse() { + void isRepeated_shouldReturnFalseIfFieldExistsAndIsRepeatedIsFalse() { HttpBinding httpBinding = httpBindingBuilder.setField(fieldBuilder.setIsRepeated(false).build()).build(); @@ -68,7 +68,7 @@ public void isRepeated_shouldReturnFalseIfFieldExistsAndIsRepeatedIsFalse() { } @Test - public void isRepeated_shouldReturnTrueIfFieldExistsAndIsRepeatedIsTue() { + void isRepeated_shouldReturnTrueIfFieldExistsAndIsRepeatedIsTue() { HttpBinding httpBinding = httpBindingBuilder.setField(fieldBuilder.setIsRepeated(true).build()).build(); @@ -76,13 +76,13 @@ public void isRepeated_shouldReturnTrueIfFieldExistsAndIsRepeatedIsTue() { } @Test - public void isEnum_shouldReturnFalseIfFieldIsNull() { + void isEnum_shouldReturnFalseIfFieldIsNull() { HttpBinding httpBinding = httpBindingBuilder.build(); Truth.assertThat(httpBinding.isEnum()).isFalse(); } @Test - public void isEnum_shouldReturnFalseIfFieldExistsAndIsEnumIsFalse() { + void isEnum_shouldReturnFalseIfFieldExistsAndIsEnumIsFalse() { HttpBinding httpBinding = httpBindingBuilder.setField(fieldBuilder.setIsEnum(false).build()).build(); @@ -90,7 +90,7 @@ public void isEnum_shouldReturnFalseIfFieldExistsAndIsEnumIsFalse() { } @Test - public void isEnum_shouldReturnTrueIfFieldExistsAndIsEnumIsTue() { + void isEnum_shouldReturnTrueIfFieldExistsAndIsEnumIsTue() { HttpBinding httpBinding = httpBindingBuilder.setField(fieldBuilder.setIsEnum(true).build()).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MessageTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MessageTest.java index 469c86c212..60d7dda9a7 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MessageTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MessageTest.java @@ -21,14 +21,14 @@ import com.google.api.generator.engine.ast.VaporReference; import com.google.common.collect.ImmutableMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MessageTest { +class MessageTest { private static final String SUB_FIELD_NAME = "table"; private static final String LEAF_FIELD_NAME = "size"; private static final String SUB_FIELD_TYPE = "TableFieldType"; - public static final VaporReference FIELD_TYPE = + private static final VaporReference FIELD_TYPE = VaporReference.builder().setPakkage("com.google").setName(SUB_FIELD_TYPE).build(); private static final String MESSAGE_NAME = "TestMessage"; private static final Message.Builder testMessageBuilder = @@ -38,7 +38,7 @@ public class MessageTest { .setType(TypeNode.OBJECT); @Test - public void validateField_shouldThrowExceptionIfFieldNameIsEmpty() { + void validateField_shouldThrowExceptionIfFieldNameIsEmpty() { Message message = testMessageBuilder.build(); IllegalStateException illegalStateException = assertThrows( @@ -50,7 +50,7 @@ public void validateField_shouldThrowExceptionIfFieldNameIsEmpty() { } @Test - public void validateField_shouldThrowExceptionIfFieldDoesNotExist() { + void validateField_shouldThrowExceptionIfFieldDoesNotExist() { Message message = testMessageBuilder.build(); String fieldName = "doesNotExist"; NullPointerException nullPointerException = @@ -65,7 +65,7 @@ public void validateField_shouldThrowExceptionIfFieldDoesNotExist() { } @Test - public void validateField_shouldThrowExceptionIfMessageDoesNotExist() { + void validateField_shouldThrowExceptionIfMessageDoesNotExist() { Field subField = Field.builder() .setName(SUB_FIELD_NAME) @@ -92,7 +92,7 @@ public void validateField_shouldThrowExceptionIfMessageDoesNotExist() { } @Test - public void validateField_shouldThrowExceptionIfFieldIsRepeated() { + void validateField_shouldThrowExceptionIfFieldIsRepeated() { Field leafField = Field.builder() .setType(TypeNode.STRING) @@ -103,7 +103,7 @@ public void validateField_shouldThrowExceptionIfFieldIsRepeated() { } @Test - public void validateField_shouldThrowExceptionIfFieldIsOfWrongType() { + void validateField_shouldThrowExceptionIfFieldIsOfWrongType() { Field leafField = Field.builder().setType(TypeNode.BOOLEAN).setName(LEAF_FIELD_NAME).build(); testLeafField(leafField); } @@ -126,7 +126,7 @@ private void testLeafField(Field leafField) { } @Test - public void validateField_shouldNotThrowExceptionIfFieldExist() { + void validateField_shouldNotThrowExceptionIfFieldExist() { Field leafField = Field.builder().setType(TypeNode.STRING).setName(LEAF_FIELD_NAME).build(); Message subMessage = createSubMessage(leafField); Map messageTypes = ImmutableMap.of(FIELD_TYPE.fullName(), subMessage); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodArgumentTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodArgumentTest.java index 691700cb3e..f0f4824c31 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodArgumentTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodArgumentTest.java @@ -19,11 +19,11 @@ import com.google.api.generator.engine.ast.TypeNode; import java.util.function.BiFunction; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MethodArgumentTest { +class MethodArgumentTest { @Test - public void compareMethodArguments() { + void compareMethodArguments() { BiFunction methodArgFn = (name, type) -> MethodArgument.builder() diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodTest.java index 65c4f6039d..238df29fd7 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodTest.java @@ -27,9 +27,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MethodTest { +class MethodTest { private static final Method METHOD = Method.builder() @@ -47,7 +47,7 @@ public class MethodTest { .build(); @Test - public void toStream() { + void toStream() { // Argument order: isClientStreaming, isServerStreaming. assertThat(Method.toStream(false, false)).isEqualTo(Method.Stream.NONE); assertThat(Method.toStream(true, false)).isEqualTo(Method.Stream.CLIENT); @@ -56,19 +56,19 @@ public void toStream() { } @Test - public void hasRoutingHeaders_shouldReturnFalseIfRoutingHeadersIsNull() { + void hasRoutingHeaders_shouldReturnFalseIfRoutingHeadersIsNull() { assertThat(METHOD.hasRoutingHeaderParams()).isFalse(); } @Test - public void hasRoutingHeaders_shouldReturnFalseIfRoutingHeadersIsEmpty() { + void hasRoutingHeaders_shouldReturnFalseIfRoutingHeadersIsEmpty() { Method method = METHOD.toBuilder().setRoutingHeaderRule(RoutingHeaderRule.builder().build()).build(); assertThat(method.hasRoutingHeaderParams()).isFalse(); } @Test - public void hasRoutingHeaders_shouldReturnTrueIfRoutingHeadersIsNotEmpty() { + void hasRoutingHeaders_shouldReturnTrueIfRoutingHeadersIsNotEmpty() { Method method = METHOD .toBuilder() @@ -81,7 +81,7 @@ public void hasRoutingHeaders_shouldReturnTrueIfRoutingHeadersIsNotEmpty() { } @Test - public void shouldSetParamsExtractor_shouldReturnTrueIfHasRoutingHeaders() { + void shouldSetParamsExtractor_shouldReturnTrueIfHasRoutingHeaders() { Method method = METHOD .toBuilder() @@ -94,15 +94,14 @@ public void shouldSetParamsExtractor_shouldReturnTrueIfHasRoutingHeaders() { } @Test - public void shouldSetParamsExtractor_shouldReturnTrueIfHasHttpBindingsAndRoutingHeadersIsNull() { + void shouldSetParamsExtractor_shouldReturnTrueIfHasHttpBindingsAndRoutingHeadersIsNull() { Method method = METHOD.toBuilder().setHttpBindings(HTTP_BINDINGS).setRoutingHeaderRule(null).build(); assertThat(method.shouldSetParamsExtractor()).isTrue(); } @Test - public void - shouldSetParamsExtractor_shouldReturnFalseIfHasHttpBindingsAndRoutingHeadersIsEmpty() { + void shouldSetParamsExtractor_shouldReturnFalseIfHasHttpBindingsAndRoutingHeadersIsEmpty() { Method method = METHOD .toBuilder() @@ -113,13 +112,13 @@ public void shouldSetParamsExtractor_shouldReturnTrueIfHasHttpBindingsAndRouting } @Test - public void shouldSetParamsExtractor_shouldReturnFalseIfHasNoHttpBindingsAndNoRoutingHeaders() { + void shouldSetParamsExtractor_shouldReturnFalseIfHasNoHttpBindingsAndNoRoutingHeaders() { Method method = METHOD.toBuilder().setHttpBindings(null).setRoutingHeaderRule(null).build(); assertThat(method.shouldSetParamsExtractor()).isFalse(); } @Test - public void hasAutoPopulatedFields_shouldReturnTrueIfMethodIsUnary() { + void hasAutoPopulatedFields_shouldReturnTrueIfMethodIsUnary() { List autoPopulatedFields = Arrays.asList("field1", "field2"); Method method = METHOD.toBuilder().setAutoPopulatedFields(autoPopulatedFields).build(); method.toStream(false, false); @@ -127,7 +126,7 @@ public void hasAutoPopulatedFields_shouldReturnTrueIfMethodIsUnary() { } @Test - public void hasAutoPopulatedFields_shouldReturnFalseIfMethodIsStreaming() { + void hasAutoPopulatedFields_shouldReturnFalseIfMethodIsStreaming() { List autoPopulatedFields = Arrays.asList("field1", "field2"); Method method = METHOD @@ -155,7 +154,7 @@ public void hasAutoPopulatedFields_shouldReturnFalseIfMethodIsStreaming() { } @Test - public void hasAutoPopulatedFields_shouldReturnFalseIfAutoPopulatedFieldsIsEmpty() { + void hasAutoPopulatedFields_shouldReturnFalseIfAutoPopulatedFieldsIsEmpty() { List autoPopulatedFields = new ArrayList<>(); Method method = METHOD @@ -168,8 +167,7 @@ public void hasAutoPopulatedFields_shouldReturnFalseIfAutoPopulatedFieldsIsEmpty } @Test - public void - isSupportedByTransport_shouldReturnTrueIfHasHttpBindingsAndIsRESTEligibleForRESTTransport() { + void isSupportedByTransport_shouldReturnTrueIfHasHttpBindingsAndIsRESTEligibleForRESTTransport() { Method methodNoStreaming = METHOD.toBuilder().setHttpBindings(HTTP_BINDINGS).setStream(Method.Stream.NONE).build(); assertThat(methodNoStreaming.isSupportedByTransport(Transport.REST)).isTrue(); @@ -179,7 +177,7 @@ public void hasAutoPopulatedFields_shouldReturnFalseIfAutoPopulatedFieldsIsEmpty } @Test - public void isSupportedByTransport_shouldReturnFalseIfNoHttpBindingsForRESTTransport() { + void isSupportedByTransport_shouldReturnFalseIfNoHttpBindingsForRESTTransport() { Method methodNoStreaming = METHOD.toBuilder().setHttpBindings(null).setStream(Method.Stream.NONE).build(); assertThat(methodNoStreaming.isSupportedByTransport(Transport.REST)).isFalse(); @@ -189,7 +187,7 @@ public void isSupportedByTransport_shouldReturnFalseIfNoHttpBindingsForRESTTrans } @Test - public void + void isSupportedByTransport_shouldReturnFalseIfHasHttpBindingsAndIsNotRESTEligibleForRESTTransport() { Method methodClientSideStreaming = METHOD.toBuilder().setHttpBindings(HTTP_BINDINGS).setStream(Method.Stream.CLIENT).build(); @@ -200,7 +198,7 @@ public void isSupportedByTransport_shouldReturnFalseIfNoHttpBindingsForRESTTrans } @Test - public void isSupportedByTransport_shouldReturnTrueForGRPCTransport() { + void isSupportedByTransport_shouldReturnTrueForGRPCTransport() { Method methodNoStreaming = METHOD.toBuilder().setHttpBindings(HTTP_BINDINGS).setStream(Method.Stream.NONE).build(); assertThat(methodNoStreaming.isSupportedByTransport(Transport.GRPC)).isTrue(); @@ -216,7 +214,7 @@ public void isSupportedByTransport_shouldReturnTrueForGRPCTransport() { } @Test - public void isSupportedByTransport_shouldThrowExceptionIfPassedGRPCRESTTransport() { + void isSupportedByTransport_shouldThrowExceptionIfPassedGRPCRESTTransport() { Method methodClientStreaming = METHOD.toBuilder().setHttpBindings(HTTP_BINDINGS).setStream(Method.Stream.CLIENT).build(); assertThrows( diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RegionTagTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RegionTagTest.java index 47667ae2ff..f0bdfe79e2 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RegionTagTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RegionTagTest.java @@ -18,9 +18,9 @@ import com.google.api.generator.test.utils.LineFormatter; import java.util.Arrays; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class RegionTagTest { +class RegionTagTest { private final String serviceName = "serviceName"; private final String apiVersion = "v1"; private final String apiShortName = "shortName"; @@ -28,7 +28,7 @@ public class RegionTagTest { private final String disambiguation = "disambiguation"; @Test - public void regionTagNoRpcName() { + void regionTagNoRpcName() { Assert.assertThrows( IllegalStateException.class, () -> @@ -42,7 +42,7 @@ public void regionTagNoRpcName() { } @Test - public void regionTagNoServiceName() { + void regionTagNoServiceName() { Assert.assertThrows( IllegalStateException.class, () -> @@ -56,7 +56,7 @@ public void regionTagNoServiceName() { } @Test - public void regionTagValidMissingFields() { + void regionTagValidMissingFields() { RegionTag regionTag = RegionTag.builder().setServiceName(serviceName).setRpcName(rpcName).build(); @@ -67,7 +67,7 @@ public void regionTagValidMissingFields() { } @Test - public void regionTagSanitizeAttributes() { + void regionTagSanitizeAttributes() { String apiVersion = "1.4.0-"; String serviceName = "service_Na@m*.e!{}"; String rpcName = "rpc _Nam^#,e [String]10"; @@ -84,7 +84,7 @@ public void regionTagSanitizeAttributes() { } @Test - public void generateRegionTagsMissingRequiredFields() { + void generateRegionTagsMissingRequiredFields() { RegionTag rtMissingShortName = RegionTag.builder() .setApiVersion(apiVersion) @@ -95,7 +95,7 @@ public void generateRegionTagsMissingRequiredFields() { } @Test - public void generateRegionTagsValidMissingFields() { + void generateRegionTagsValidMissingFields() { RegionTag regionTag = RegionTag.builder() .setApiShortName(apiShortName) @@ -109,7 +109,7 @@ public void generateRegionTagsValidMissingFields() { } @Test - public void generateRegionTagsAllFields() { + void generateRegionTagsAllFields() { RegionTag regionTag = RegionTag.builder() .setApiShortName(apiShortName) @@ -126,7 +126,7 @@ public void generateRegionTagsAllFields() { } @Test - public void generateRegionTagTag() { + void generateRegionTagTag() { RegionTag regionTag = RegionTag.builder() .setApiShortName(apiShortName) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ResourceNameTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ResourceNameTest.java index 0cd6620c51..e48c504539 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ResourceNameTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ResourceNameTest.java @@ -18,9 +18,9 @@ import com.google.common.truth.Truth; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ResourceNameTest { +class ResourceNameTest { private final ResourceName resName = ResourceName.builder() .setVariableName("topic") @@ -31,7 +31,7 @@ public class ResourceNameTest { .build(); @Test - public void getMatchingPattern() { + void getMatchingPattern() { HttpBindings bindings = HttpBindings.builder() .setHttpVerb(HttpVerb.PUT) @@ -45,7 +45,7 @@ public void getMatchingPattern() { } @Test - public void getMatchingPatternFromAdditionalPattern() { + void getMatchingPatternFromAdditionalPattern() { HttpBindings bindings = HttpBindings.builder() .setHttpVerb(HttpVerb.PUT) @@ -59,7 +59,7 @@ public void getMatchingPatternFromAdditionalPattern() { } @Test - public void getMatchingPatternNoMatch() { + void getMatchingPatternNoMatch() { HttpBindings bindings = HttpBindings.builder() .setHttpVerb(HttpVerb.PUT) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RoutingHeaderParamTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RoutingHeaderParamTest.java index 8c2d1d361e..9311de8342 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RoutingHeaderParamTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/RoutingHeaderParamTest.java @@ -18,12 +18,12 @@ import com.google.api.generator.gapic.model.RoutingHeaderRule.RoutingHeaderParam; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class RoutingHeaderParamTest { +class RoutingHeaderParamTest { @Test - public void getDescendantFieldNames_shouldSplitFieldNameByDot() { + void getDescendantFieldNames_shouldSplitFieldNameByDot() { RoutingHeaderParam routingHeaderParam = RoutingHeaderParam.create("table.name", "name", "/abc/dec"); List descendantFieldNames = routingHeaderParam.getDescendantFieldNames(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/SampleTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/SampleTest.java index 7b880ba394..9f13646d9a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/SampleTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/SampleTest.java @@ -22,9 +22,9 @@ import java.util.Arrays; import java.util.List; import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SampleTest { +class SampleTest { private final RegionTag regionTag = RegionTag.builder().setServiceName("serviceName").setRpcName("rpcName").build(); private final List sampleBody = @@ -33,14 +33,14 @@ public class SampleTest { Arrays.asList(CommentStatement.withComment(BlockComment.withComment("apache license"))); @Test - public void sampleNoRegionTag() { + void sampleNoRegionTag() { Assert.assertThrows( IllegalStateException.class, () -> Sample.builder().setBody(sampleBody).setFileHeader(header).build()); } @Test - public void sampleValidMissingFields() { + void sampleValidMissingFields() { Sample sample = Sample.builder().setRegionTag(regionTag).build(); Assert.assertEquals(ImmutableList.of(), sample.fileHeader()); @@ -50,7 +50,7 @@ public void sampleValidMissingFields() { } @Test - public void sampleWithHeader() { + void sampleWithHeader() { Sample sample = Sample.builder().setRegionTag(regionTag).setBody(sampleBody).build(); Assert.assertEquals(ImmutableList.of(), sample.fileHeader()); @@ -59,7 +59,7 @@ public void sampleWithHeader() { } @Test - public void sampleNameWithRegionTag() { + void sampleNameWithRegionTag() { Sample sample = Sample.builder().setRegionTag(regionTag).build(); Assert.assertEquals("SyncRpcName", sample.name()); @@ -73,7 +73,7 @@ public void sampleNameWithRegionTag() { } @Test - public void sampleNameWithRegionTagCanonical() { + void sampleNameWithRegionTagCanonical() { String disambig = "Disambiguation"; Sample sample = Sample.builder().setRegionTag(regionTag.withOverloadDisambiguation(disambig)).build(); @@ -86,7 +86,7 @@ public void sampleNameWithRegionTagCanonical() { } @Test - public void sampleCanonicalOverload() { + void sampleCanonicalOverload() { String disambig = "Disambiguation"; Sample sample = Sample.builder().setRegionTag(regionTag.withOverloadDisambiguation(disambig)).build(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ServiceTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ServiceTest.java index 10b82ec585..624431fdd8 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ServiceTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/ServiceTest.java @@ -18,16 +18,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import com.google.api.generator.engine.ast.TypeNode; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ServiceTest { +class ServiceTest { private static final String SHOWCASE_PACKAGE_NAME = "com.google.showcase.v1beta1"; private Service.Builder testServiceBuilder; @@ -46,8 +47,8 @@ public class ServiceTest { .setIsAsteriskBody(false) .setHttpVerb(HttpBindings.HttpVerb.GET); - @Before - public void init() { + @BeforeEach + void init() { testServiceBuilder = Service.builder() .setName("Echo") @@ -60,49 +61,49 @@ public void init() { } @Test - public void apiShortName_shouldReturnApiShortNameIfHostContainsRegionalEndpoint() { + void apiShortName_shouldReturnApiShortNameIfHostContainsRegionalEndpoint() { String defaultHost = "us-east1-pubsub.googleapis.com"; Service testService = testServiceBuilder.setDefaultHost(defaultHost).build(); assertEquals("pubsub", testService.apiShortName()); } @Test - public void apiShortName_shouldReturnApiShortName() { + void apiShortName_shouldReturnApiShortName() { String defaultHost = "logging.googleapis.com"; Service testService = testServiceBuilder.setDefaultHost(defaultHost).build(); assertEquals("logging", testService.apiShortName()); } @Test - public void apiShortName_shouldReturnApiShortNameForIam() { + void apiShortName_shouldReturnApiShortNameForIam() { String defaultHost = "iam-meta-api.googleapis.com"; Service testService = testServiceBuilder.setDefaultHost(defaultHost).build(); assertEquals("iam", testService.apiShortName()); } @Test - public void apiShortName_shouldReturnHostIfNoPeriods() { + void apiShortName_shouldReturnHostIfNoPeriods() { String defaultHost = "logging:7469"; Service testService = testServiceBuilder.setDefaultHost(defaultHost).build(); assertEquals("logging:7469", testService.apiShortName()); } @Test - public void packageVersion_shouldReturnVersionIfMatch() { + void packageVersion_shouldReturnVersionIfMatch() { String protoPackage = "com.google.showcase.v1"; Service testService = testServiceBuilder.setProtoPakkage(protoPackage).build(); assertEquals("v1", testService.packageVersion()); } @Test - public void packageVersion_shouldReturnEmptyIfNoMatch() { + void packageVersion_shouldReturnEmptyIfNoMatch() { String protoPackage = "com.google.showcase"; Service testService = testServiceBuilder.setProtoPakkage(protoPackage).build(); assertEquals("", testService.packageVersion()); } @Test - public void apiVersion_shouldReturnApiVersion() { + void apiVersion_shouldReturnApiVersion() { String apiVersion = "v1_20230601"; Service testService = testServiceBuilder.setApiVersion(apiVersion).build(); assertTrue(testService.hasApiVersion()); @@ -110,14 +111,14 @@ public void apiVersion_shouldReturnApiVersion() { } @Test - public void apiVersion_shouldReturnNoApiVersionWhenNull() { + void apiVersion_shouldReturnNoApiVersionWhenNull() { Service testService = testServiceBuilder.build(); assertNull(testService.apiVersion()); assertFalse(testService.hasApiVersion()); } @Test - public void apiVersion_shouldReturnNoApiVersionWhenEmpty() { + void apiVersion_shouldReturnNoApiVersionWhenEmpty() { String apiVersion = ""; Service testService = testServiceBuilder.setApiVersion(apiVersion).build(); assertEquals("", testService.apiVersion()); @@ -125,16 +126,14 @@ public void apiVersion_shouldReturnNoApiVersionWhenEmpty() { } @Test - public void - hasAnyEnabledMethodsForTransport_shouldReturnFalseForEmptyMethodListForBothTransports() { + void hasAnyEnabledMethodsForTransport_shouldReturnFalseForEmptyMethodListForBothTransports() { Service testService = testServiceBuilder.setMethods(ImmutableList.of()).build(); assertThat(testService.hasAnyEnabledMethodsForTransport(Transport.GRPC)).isFalse(); assertThat(testService.hasAnyEnabledMethodsForTransport(Transport.REST)).isFalse(); } @Test - public void - hasAnyEnabledMethodsForTransport_shouldReturnTrueForAnyNonEmptyMethodListGRPCTransport() { + void hasAnyEnabledMethodsForTransport_shouldReturnTrueForAnyNonEmptyMethodListGRPCTransport() { Method testMethod1 = testMethodBuilder .setStream(Method.Stream.NONE) @@ -157,7 +156,7 @@ public void apiVersion_shouldReturnNoApiVersionWhenEmpty() { } @Test - public void + void hasAnyEnabledMethodsForTransport_shouldReturnTrueForAnyNonEmptyAndValidMethodListRESTTransport() { Method testMethod1 = testMethodBuilder @@ -181,7 +180,7 @@ public void apiVersion_shouldReturnNoApiVersionWhenEmpty() { } @Test - public void + void hasAnyEnabledMethodsForTransport_shouldReturnFalseForAnyNonEmptyButInvalidMethodListRESTTransport() { Method testMethod1 = testMethodBuilder @@ -204,20 +203,22 @@ public void apiVersion_shouldReturnNoApiVersionWhenEmpty() { assertThat(testService3.hasAnyEnabledMethodsForTransport(Transport.REST)).isFalse(); } - @Test(expected = IllegalArgumentException.class) - public void hasAnyEnabledMethodsForTransport_shouldThrowExceptionForGRPCRESTTransport() { + @Test + void hasAnyEnabledMethodsForTransport_shouldThrowExceptionForGRPCRESTTransport() { Service testService = testServiceBuilder.build(); - testService.hasAnyEnabledMethodsForTransport(Transport.GRPC_REST); + assertThrows( + IllegalArgumentException.class, + () -> testService.hasAnyEnabledMethodsForTransport(Transport.GRPC_REST)); } @Test - public void hostServiceName_googleApisDefaultHost() { + void hostServiceName_googleApisDefaultHost() { Service service = testServiceBuilder.setDefaultHost("test.googleapis.com").build(); assertThat(service.hostServiceName()).isEqualTo("test"); } @Test - public void hostServiceName_nonGoogleApisDefaultHost() { + void hostServiceName_nonGoogleApisDefaultHost() { // Default Host is localhost:7469 Service service = testServiceBuilder.build(); assertThat(service.hostServiceName()).isEqualTo(""); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/TransportTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/TransportTest.java index f83c2e16a8..f5f4b1ca8a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/TransportTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/TransportTest.java @@ -3,46 +3,35 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -public class TransportTest { - - private final String input; - private final Transport expected; - - @Parameterized.Parameters - public static Collection primeNumbers() { - return Arrays.asList( - new Object[][] { - {"grpc", Transport.GRPC}, - {"Grpc", Transport.GRPC}, - {"gRPC", Transport.GRPC}, - {"rest", Transport.REST}, - {"REST", Transport.REST}, - {"rESt", Transport.REST}, - {"grpc+rest", Transport.GRPC_REST}, - {"gRPC+REST", Transport.GRPC_REST}, - {"grPc+rEst", Transport.GRPC_REST} - }); +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class TransportTest { + + static Stream data() { + return Stream.of( + Arguments.of("grpc", Transport.GRPC), + Arguments.of("Grpc", Transport.GRPC), + Arguments.of("gRPC", Transport.GRPC), + Arguments.of("rest", Transport.REST), + Arguments.of("REST", Transport.REST), + Arguments.of("rESt", Transport.REST), + Arguments.of("grpc+rest", Transport.GRPC_REST), + Arguments.of("gRPC+REST", Transport.GRPC_REST), + Arguments.of("grPc+rEst", Transport.GRPC_REST)); } - public TransportTest(String input, Transport expected) { - this.input = input; - this.expected = expected; - } - - @Test - public void testParse_returnsValidTransport() { + @ParameterizedTest + @MethodSource("data") + void testParse_returnsValidTransport(String input, Transport expected) { assertThat(expected).isEqualTo(Transport.parse(input)); } @Test - public void testParse_throwsException() { + void testParse_throwsException() { assertThrows(IllegalArgumentException.class, () -> Transport.parse("invalid transport")); assertThrows(IllegalArgumentException.class, () -> Transport.parse("grHttpc")); } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/BatchingSettingsConfigParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/BatchingSettingsConfigParserTest.java index 3430c2585d..244346766a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/BatchingSettingsConfigParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/BatchingSettingsConfigParserTest.java @@ -24,14 +24,14 @@ import java.nio.file.Paths; import java.util.List; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class BatchingSettingsConfigParserTest { +class BatchingSettingsConfigParserTest { private static final String YAML_DIRECTORY = "src/test/resources/"; @Test - public void parseGapicSettings_plain() { + void parseGapicSettings_plain() { String filename = "datastore_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = @@ -40,7 +40,7 @@ public void parseGapicSettings_plain() { } @Test - public void parseGapicSettings_noMethodSettings() { + void parseGapicSettings_noMethodSettings() { String filename = "showcase_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = @@ -49,7 +49,7 @@ public void parseGapicSettings_noMethodSettings() { } @Test - public void parseBatchingSettings_logging() { + void parseBatchingSettings_logging() { String filename = "logging_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = @@ -82,7 +82,7 @@ public void parseBatchingSettings_logging() { } @Test - public void parseBatchingSettings_pubsub() { + void parseBatchingSettings_pubsub() { String filename = "pubsub_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLanguageSettingsParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLanguageSettingsParserTest.java index 868231d516..c41b770bdd 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLanguageSettingsParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLanguageSettingsParserTest.java @@ -21,14 +21,14 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GapicLanguageSettingsParserTest { +class GapicLanguageSettingsParserTest { private static final String YAML_DIRECTORY = "src/test/resources/"; @Test - public void parseLanguageSettings_onlyInterfacePresent() { + void parseLanguageSettings_onlyInterfacePresent() { String filename = "datastore_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional settingsOpt = @@ -40,7 +40,7 @@ public void parseLanguageSettings_onlyInterfacePresent() { } @Test - public void parseLanguageSettings_methodNameOverridesPresent() { + void parseLanguageSettings_methodNameOverridesPresent() { String filename = "logging_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional settingsOpt = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLroRetrySettingsParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLroRetrySettingsParserTest.java index 0c7f8e7d82..0ecdc78fbe 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLroRetrySettingsParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/GapicLroRetrySettingsParserTest.java @@ -22,15 +22,15 @@ import java.nio.file.Paths; import java.util.List; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GapicLroRetrySettingsParserTest { +class GapicLroRetrySettingsParserTest { private static final double DELTA = 0.0001; private static final String YAML_DIRECTORY = "src/test/resources/"; @Test - public void parseLroRetrySettings_methodsPresentNoLroRetrySettings() { + void parseLroRetrySettings_methodsPresentNoLroRetrySettings() { String filename = "datastore_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = @@ -39,7 +39,7 @@ public void parseLroRetrySettings_methodsPresentNoLroRetrySettings() { } @Test - public void parseGapicSettings_noMethodSettings() { + void parseGapicSettings_noMethodSettings() { String filename = "showcase_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = @@ -48,7 +48,7 @@ public void parseGapicSettings_noMethodSettings() { } @Test - public void parseLroRetrySettings_lroRetrySettingsPresent() { + void parseLroRetrySettings_lroRetrySettingsPresent() { String filename = "dataproc_gapic.yaml"; Path path = Paths.get(YAML_DIRECTORY, filename); Optional> settingsOpt = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java index 30cf4d4b77..77a0440319 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java @@ -31,12 +31,12 @@ import java.util.HashSet; import java.util.Map; import java.util.stream.Collectors; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -public class HttpRuleParserTest { +class HttpRuleParserTest { @Test - public void parseHttpAnnotation_basic() { + void parseHttpAnnotation_basic() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals("Testing", testingService.getName()); @@ -61,7 +61,7 @@ public void parseHttpAnnotation_basic() { } @Test - public void parseHttpAnnotation_multipleBindings() { + void parseHttpAnnotation_multipleBindings() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals("Testing", testingService.getName()); @@ -81,7 +81,7 @@ public void parseHttpAnnotation_multipleBindings() { } @Test - public void parseHttpAnnotation_missingFieldFromMessage() { + void parseHttpAnnotation_missingFieldFromMessage() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals("Testing", testingService.getName()); @@ -97,8 +97,7 @@ public void parseHttpAnnotation_missingFieldFromMessage() { } @Test - public void - parseHttpAnnotation_shouldPutAllFieldsIntoQueryParamsIfPathParamAndBodyAreNotConfigured() { + void parseHttpAnnotation_shouldPutAllFieldsIntoQueryParamsIfPathParamAndBodyAreNotConfigured() { FileDescriptor fileDescriptor = HttpRuleParserTestingOuterClass.getDescriptor(); ServiceDescriptor serviceDescriptor = fileDescriptor.getServices().get(0); assertEquals("HttpRuleParserTesting", serviceDescriptor.getName()); @@ -124,7 +123,7 @@ public void parseHttpAnnotation_missingFieldFromMessage() { Truth.assertThat(new HashSet<>(actual.queryParameters())).containsExactly(expected1, expected2); } - @Ignore + @Disabled @Test // request // / \ @@ -138,7 +137,7 @@ public void parseHttpAnnotation_missingFieldFromMessage() { // We need to either traverse all the leaf level fields and exclude field in the generator or pass // the excluded fields to gax-java. Re-enable this test once // https://github.com/googleapis/sdk-platform-java/issues/1041 is fixed - public void parseHttpAnnotation_shouldExcludeFieldsFromQueryParamsIfPathParamsAreConfigured() { + void parseHttpAnnotation_shouldExcludeFieldsFromQueryParamsIfPathParamsAreConfigured() { FileDescriptor fileDescriptor = HttpRuleParserTestingOuterClass.getDescriptor(); ServiceDescriptor serviceDescriptor = fileDescriptor.getServices().get(0); assertEquals("HttpRuleParserTesting", serviceDescriptor.getName()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/MethodSignatureParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/MethodSignatureParserTest.java index 68a2bbc66b..10bb943c6c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/MethodSignatureParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/MethodSignatureParserTest.java @@ -28,12 +28,12 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MethodSignatureParserTest { +class MethodSignatureParserTest { @Test - public void flattenMethodSignatures_basic() { + void flattenMethodSignatures_basic() { String fooName = "fooName"; TypeNode fooTypeOne = TypeNode.withReference( @@ -70,7 +70,7 @@ public void flattenMethodSignatures_basic() { } @Test - public void flattenMethodSignatures_oneToMany() { + void flattenMethodSignatures_oneToMany() { String fooName = "fooName"; String anInt = "anInt"; @@ -110,7 +110,7 @@ public void flattenMethodSignatures_oneToMany() { } @Test - public void flattenMethodSignatures_manyToOne() { + void flattenMethodSignatures_manyToOne() { String fooName = "fooName"; String anInt = "anInt"; @@ -150,7 +150,7 @@ public void flattenMethodSignatures_manyToOne() { } @Test - public void flattenMethodSignatures_manyToMany() { + void flattenMethodSignatures_manyToMany() { String fooName = "fooName"; String barName = "barName"; String anInt = "anInt"; diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java index f06c464055..66f2bf49a9 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java @@ -56,10 +56,10 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ParserTest { +class ParserTest { private static final String ECHO_PACKAGE = "com.google.showcase.v1beta1"; // TODO(miraleung): Backfill with more tests (e.g. field, message, methods) for Parser.java. private ServiceDescriptor echoService; @@ -69,8 +69,8 @@ public class ParserTest { private Optional serviceYamlProtoOpt; - @Before - public void setUp() { + @BeforeEach + void setUp() { echoFileDescriptor = EchoOuterClass.getDescriptor(); echoService = echoFileDescriptor.getServices().get(0); String yamlFilename = "echo_v1beta1.yaml"; @@ -80,7 +80,7 @@ public void setUp() { } @Test - public void parseMessages_basic() { + void parseMessages_basic() { // TODO(miraleung): Add more tests for oneofs and other message-parsing edge cases. Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -116,7 +116,7 @@ public void parseMessages_basic() { } @Test - public void parseMessages_fieldNameConflicts() { + void parseMessages_fieldNameConflicts() { FileDescriptor bookshopFileDescriptor = BookshopProto.getDescriptor(); Map messageTypes = Parser.parseMessages(bookshopFileDescriptor); Message requestMessage = messageTypes.get("com.google.bookshop.v1beta1.GetBookRequest"); @@ -127,7 +127,7 @@ public void parseMessages_fieldNameConflicts() { } @Test - public void parseMethods_basic() { + void parseMethods_basic() { Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Set outputResourceNames = new HashSet<>(); @@ -190,7 +190,7 @@ public void parseMethods_basic() { } @Test - public void parseMethods_basicLro() { + void parseMethods_basicLro() { Map messageTypes = Parser.parseMessages(echoFileDescriptor); Map resourceNames = Parser.parseResourceNames(echoFileDescriptor); Set outputResourceNames = new HashSet<>(); @@ -218,7 +218,7 @@ public void parseMethods_basicLro() { } @Test - public void parseLro_missingResponseType() { + void parseLro_missingResponseType() { Map messageTypes = Parser.parseMessages(echoFileDescriptor); MethodDescriptor waitMethodDescriptor = echoService.getMethods().get(7); assertEquals("Wait", waitMethodDescriptor.getName()); @@ -228,7 +228,7 @@ public void parseLro_missingResponseType() { } @Test - public void parseLro_missingMetadataType() { + void parseLro_missingMetadataType() { Map messageTypes = Parser.parseMessages(echoFileDescriptor); MethodDescriptor waitMethodDescriptor = echoService.getMethods().get(7); assertEquals("Wait", waitMethodDescriptor.getName()); @@ -238,7 +238,7 @@ public void parseLro_missingMetadataType() { } @Test - public void parseMethodSignatures_empty() { + void parseMethodSignatures_empty() { // TODO(miraleung): Move this to MethodSignatureParserTest. MethodDescriptor methodDescriptor = echoService.getMethods().get(5); assertEquals("PagedExpand", methodDescriptor.getName()); @@ -259,7 +259,7 @@ public void parseMethodSignatures_empty() { } @Test - public void parseMethodSignatures_validArgstAndEmptyString() { + void parseMethodSignatures_validArgstAndEmptyString() { // TODO(miraleung): Move this to MethodSignatureParserTest. MethodDescriptor methodDescriptor = echoService.getMethods().get(0); assertEquals("Echo", methodDescriptor.getName()); @@ -282,7 +282,7 @@ public void parseMethodSignatures_validArgstAndEmptyString() { } @Test - public void parseMethodSignatures_basic() { + void parseMethodSignatures_basic() { MethodDescriptor echoMethodDescriptor = echoService.getMethods().get(0); TypeNode inputType = TypeParser.parseType(echoMethodDescriptor.getInputType()); Map messageTypes = Parser.parseMessages(echoFileDescriptor); @@ -361,7 +361,7 @@ public void parseMethodSignatures_basic() { } @Test - public void parseMessagesAndResourceNames_update() { + void parseMessagesAndResourceNames_update() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map messageTypes = Parser.parseMessages(lockerServiceFileDescriptor); @@ -381,7 +381,7 @@ public void parseMessagesAndResourceNames_update() { } @Test - public void parseMessages_fieldsHaveResourceReferences() { + void parseMessages_fieldsHaveResourceReferences() { FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor(); Map messageTypes = Parser.parseMessages(lockerServiceFileDescriptor); @@ -423,7 +423,7 @@ public void parseMessages_fieldsHaveResourceReferences() { } @Test - public void parseFields_mapType() { + void parseFields_mapType() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals(testingService.getName(), "Testing"); @@ -442,7 +442,7 @@ public void parseFields_mapType() { } @Test - public void parseFields_autoPopulated() { + void parseFields_autoPopulated() { Map messageTypes = Parser.parseMessages(AutoPopulateFieldTestingOuterClass.getDescriptor()); Message message = @@ -474,7 +474,7 @@ public void parseFields_autoPopulated() { } @Test - public void parseAutoPopulatedMethodsAndFields_exists() { + void parseAutoPopulatedMethodsAndFields_exists() { String yamlFilename = "auto_populate_field_testing.yaml"; Path yamlPath = Paths.get(YAML_DIRECTORY, yamlFilename); Map> autoPopulatedMethodsWithFields = @@ -496,7 +496,7 @@ public void parseAutoPopulatedMethodsAndFields_exists() { } @Test - public void parseAutoPopulatedMethodsAndFields_doesNotExist() { + void parseAutoPopulatedMethodsAndFields_doesNotExist() { String yamlFilename = "logging.yaml"; Path yamlPath = Paths.get(YAML_DIRECTORY, yamlFilename); Optional serviceYamlProtoOpt_Null = ServiceYamlParser.parse(yamlPath.toString()); @@ -507,12 +507,12 @@ public void parseAutoPopulatedMethodsAndFields_doesNotExist() { } @Test - public void parseAutoPopulatedMethodsAndFields_returnsEmptyMapIfServiceYamlIsNull() { + void parseAutoPopulatedMethodsAndFields_returnsEmptyMapIfServiceYamlIsNull() { assertEquals(true, Parser.parseAutoPopulatedMethodsAndFields(Optional.empty()).isEmpty()); } @Test - public void parseAutoPopulatedMethodsAndFields_returnsMapOfMethodsAndAutoPopulatedFields() { + void parseAutoPopulatedMethodsAndFields_returnsMapOfMethodsAndAutoPopulatedFields() { MethodSettings testMethodSettings = MethodSettings.newBuilder() .setSelector("test_method") @@ -546,17 +546,17 @@ public void parseAutoPopulatedMethodsAndFields_returnsMapOfMethodsAndAutoPopulat } @Test - public void hasMethodSettings_shouldReturnFalseIfServiceYamlDoesNotExist() { + void hasMethodSettings_shouldReturnFalseIfServiceYamlDoesNotExist() { assertEquals(false, Parser.hasMethodSettings(Optional.empty())); } @Test - public void hasMethodSettings_shouldReturnFalseIfServiceYamlDoesNotHavePublishing() { + void hasMethodSettings_shouldReturnFalseIfServiceYamlDoesNotHavePublishing() { assertEquals(false, Parser.hasMethodSettings(Optional.of(Service.newBuilder().build()))); } @Test - public void hasMethodSettings_shouldReturnTrueIfServiceYamlHasNonEmptyMethodSettings() { + void hasMethodSettings_shouldReturnTrueIfServiceYamlHasNonEmptyMethodSettings() { MethodSettings testMethodSettings = MethodSettings.newBuilder().setSelector("test_method").build(); Publishing testPublishing = @@ -568,7 +568,7 @@ public void hasMethodSettings_shouldReturnTrueIfServiceYamlHasNonEmptyMethodSett } @Test - public void parseResourceNames_inputTypeHasReferenceNotInMethodSignature() { + void parseResourceNames_inputTypeHasReferenceNotInMethodSignature() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); assertEquals(testingService.getName(), "Testing"); @@ -589,7 +589,7 @@ public void parseResourceNames_inputTypeHasReferenceNotInMethodSignature() { } @Test - public void sanitizeDefaultHost_basic() { + void sanitizeDefaultHost_basic() { String defaultHost = "localhost:1234"; assertEquals(defaultHost, Parser.sanitizeDefaultHost(defaultHost)); @@ -598,7 +598,7 @@ public void sanitizeDefaultHost_basic() { } @Test - public void parseNestedProtoTypeName() { + void parseNestedProtoTypeName() { assertEquals("MutateJobMetadata", Parser.parseNestedProtoTypeName("MutateJobMetadata")); assertEquals( "MutateJob.MutateJobMetadata", @@ -610,7 +610,7 @@ public void parseNestedProtoTypeName() { } @Test - public void parseServiceApiVersionTest() { + void parseServiceApiVersionTest() { FileDescriptor apiVersionFileDescriptor = ApiVersionTestingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(apiVersionFileDescriptor); Map resourceNames = Parser.parseResourceNames(apiVersionFileDescriptor); @@ -629,7 +629,7 @@ public void parseServiceApiVersionTest() { } @Test - public void parseServiceWithoutApiVersionTest() { + void parseServiceWithoutApiVersionTest() { FileDescriptor apiVersionFileDescriptor = ApiVersionTestingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(apiVersionFileDescriptor); Map resourceNames = Parser.parseResourceNames(apiVersionFileDescriptor); @@ -648,7 +648,7 @@ public void parseServiceWithoutApiVersionTest() { } @Test - public void parseServiceWithEmptyApiVersionTest() { + void parseServiceWithEmptyApiVersionTest() { FileDescriptor apiVersionFileDescriptor = ApiVersionTestingOuterClass.getDescriptor(); Map messageTypes = Parser.parseMessages(apiVersionFileDescriptor); Map resourceNames = Parser.parseResourceNames(apiVersionFileDescriptor); @@ -668,7 +668,7 @@ public void parseServiceWithEmptyApiVersionTest() { } @Test - public void testServiceWithoutApiVersionParsed() { + void testServiceWithoutApiVersionParsed() { FileDescriptor bookshopFileDescriptor = BookshopProto.getDescriptor(); Map messageTypes = Parser.parseMessages(bookshopFileDescriptor); Map resourceNames = Parser.parseResourceNames(bookshopFileDescriptor); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PatternParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PatternParserTest.java index 764c719af7..1ba2dd7d95 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PatternParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PatternParserTest.java @@ -17,22 +17,22 @@ import static com.google.common.truth.Truth.assertThat; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PatternParserTest { +class PatternParserTest { @Test - public void getPattenBindings_shouldReturnEmptySetIfPatternIsEmpty() { + void getPattenBindings_shouldReturnEmptySetIfPatternIsEmpty() { assertThat(PatternParser.getPatternBindings("")).isEmpty(); } @Test - public void getPattenBindings_shouldFilterOutUnboundVariables() { + void getPattenBindings_shouldFilterOutUnboundVariables() { Set actual = PatternParser.getPatternBindings("{routing_id=projects/*}/**"); assertThat(actual).hasSize(1); } @Test - public void getPattenBindings_shouldReturnBindingsInNatualOrder() { + void getPattenBindings_shouldReturnBindingsInNatualOrder() { Set actual = PatternParser.getPatternBindings("{routing_id=projects/*}/{name=instance/*}"); assertThat(actual).containsExactly("name", "routing_id").inOrder(); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java index bebe828f71..83e75f87f5 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/PluginArgumentParserTest.java @@ -22,11 +22,11 @@ import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PluginArgumentParserTest { +class PluginArgumentParserTest { @Test - public void parseJsonPath_onlyOnePresent() { + void parseJsonPath_onlyOnePresent() { String jsonPath = "/tmp/grpc_service_config.json"; assertEquals( jsonPath, @@ -34,7 +34,7 @@ public void parseJsonPath_onlyOnePresent() { } @Test - public void parseJsonPath_returnsFirstOneFound() { + void parseJsonPath_returnsFirstOneFound() { String jsonPathOne = "/tmp/foobar_grpc_service_config.json"; String jsonPathTwo = "/tmp/some_other_grpc_service_config.json"; assertEquals( @@ -49,7 +49,7 @@ public void parseJsonPath_returnsFirstOneFound() { } @Test - public void parseJsonPath_similarFileAppearsFirst() { + void parseJsonPath_similarFileAppearsFirst() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = "/tmp/something_gapic.yaml"; String rawArgument = @@ -65,7 +65,7 @@ public void parseJsonPath_similarFileAppearsFirst() { } @Test - public void parseJsonPath_argumentHasSpaces() { + void parseJsonPath_argumentHasSpaces() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = "/tmp/something_gapic.yaml"; String rawArgument = @@ -81,7 +81,7 @@ public void parseJsonPath_argumentHasSpaces() { } @Test - public void parseJsonPath_restAreEmpty() { + void parseJsonPath_restAreEmpty() { String jsonPath = "/tmp/foobar_grpc_service_config.json"; String gapicPath = ""; String rawArgument = @@ -90,14 +90,14 @@ public void parseJsonPath_restAreEmpty() { } @Test - public void parseJsonPath_noneFound() { + void parseJsonPath_noneFound() { String gapicPath = "/tmp/something_gapic.yaml"; String rawArgument = String.join(",", Arrays.asList(gapicPath)); assertFalse(PluginArgumentParser.parseJsonConfigPath(rawArgument).isPresent()); } @Test - public void parseGapicYamlPath_onlyOnePresent() { + void parseGapicYamlPath_onlyOnePresent() { String gapicPath = "/tmp/something_gapic.yaml"; assertEquals( gapicPath, @@ -105,7 +105,7 @@ public void parseGapicYamlPath_onlyOnePresent() { } @Test - public void parseGapicYamlPath_returnsFirstOneFound() { + void parseGapicYamlPath_returnsFirstOneFound() { String gapicPathOne = "/tmp/something_gapic.yaml"; String gapicPathTwo = "/tmp/other_gapic.yaml"; assertEquals( @@ -119,7 +119,7 @@ public void parseGapicYamlPath_returnsFirstOneFound() { } @Test - public void parseGapicYamlPath_similarFileAppearsFirst() { + void parseGapicYamlPath_similarFileAppearsFirst() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = "/tmp/something_gapic.yaml"; String rawArgument = @@ -134,7 +134,7 @@ public void parseGapicYamlPath_similarFileAppearsFirst() { } @Test - public void parseGapicYamlPath_restAreEmpty() { + void parseGapicYamlPath_restAreEmpty() { String jsonPath = ""; String gapicPath = "/tmp/something_gapic.yaml"; String rawArgument = @@ -143,7 +143,7 @@ public void parseGapicYamlPath_restAreEmpty() { } @Test - public void parseGapicYamlPath_noneFound() { + void parseGapicYamlPath_noneFound() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = ""; String rawArgument = @@ -152,7 +152,7 @@ public void parseGapicYamlPath_noneFound() { } @Test - public void parseServiceYamlPath_onlyOnePresent() { + void parseServiceYamlPath_onlyOnePresent() { String servicePath = "/tmp/something.yaml"; assertEquals( servicePath, @@ -160,7 +160,7 @@ public void parseServiceYamlPath_onlyOnePresent() { } @Test - public void parseServiceYamlPath_returnsFirstOneFound() { + void parseServiceYamlPath_returnsFirstOneFound() { String servicePathOne = "/tmp/something.yaml"; String servicePathTwo = "/tmp/other.yaml"; assertEquals( @@ -174,7 +174,7 @@ public void parseServiceYamlPath_returnsFirstOneFound() { } @Test - public void parseServiceYamlPath_gapicFilePresent() { + void parseServiceYamlPath_gapicFilePresent() { String gapicPath = "/tmp/something_gapic.yaml"; String servicePath = "/tmp/something.yaml"; // Both passed under the service yaml flag. @@ -203,7 +203,7 @@ public void parseServiceYamlPath_gapicFilePresent() { } @Test - public void parseServiceYamlPath_similarFileAppearsFirst() { + void parseServiceYamlPath_similarFileAppearsFirst() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = "/tmp/something_gapic.yaml"; String servicePath = "/tmp/something.yaml"; @@ -220,7 +220,7 @@ public void parseServiceYamlPath_similarFileAppearsFirst() { } @Test - public void parseServiceYamlPath_noneFound() { + void parseServiceYamlPath_noneFound() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = ""; String rawArgument = @@ -229,7 +229,7 @@ public void parseServiceYamlPath_noneFound() { } @Test - public void hasMetadataFlag() { + void hasMetadataFlag() { CodeGeneratorRequest request = CodeGeneratorRequest.newBuilder() .setParameter(String.join(",", KEY_METADATA, "does-not-matter")) @@ -238,7 +238,7 @@ public void hasMetadataFlag() { } @Test - public void hasNumericEnumFlag() { + void hasNumericEnumFlag() { CodeGeneratorRequest request = CodeGeneratorRequest.newBuilder() .setParameter(String.join(",", KEY_NUMERIC_ENUM, "does-not-matter")) @@ -247,7 +247,7 @@ public void hasNumericEnumFlag() { } @Test - public void hasFlag_noneFound() { + void hasFlag_noneFound() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = ""; String rawArgument = @@ -261,7 +261,7 @@ public void hasFlag_noneFound() { } @Test - public void hasFlag_flagFound() { + void hasFlag_flagFound() { String jsonPath = "/tmp/foo_grpc_service_config.json"; String gapicPath = ""; String rawArgument = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceNameParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceNameParserTest.java index 04b6622b5a..d10cf818b3 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceNameParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceNameParserTest.java @@ -31,21 +31,21 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ResourceNameParserTest { +class ResourceNameParserTest { private static final String MAIN_PACKAGE = "com.google.testgapic.v1beta1"; private FileDescriptor lockerServiceFileDescriptor; - @Before - public void setUp() { + @BeforeEach + void setUp() { lockerServiceFileDescriptor = LockerProto.getDescriptor(); } @Test - public void parseResourceNames_basicOnePattern() { + void parseResourceNames_basicOnePattern() { Map typeStringsToResourceNames = ResourceNameParser.parseResourceNamesFromFile(lockerServiceFileDescriptor); assertEquals(4, typeStringsToResourceNames.size()); @@ -63,7 +63,7 @@ public void parseResourceNames_basicOnePattern() { } @Test - public void parseResourceNames_basicTwoPatterns() { + void parseResourceNames_basicTwoPatterns() { Map typeStringsToResourceNames = ResourceNameParser.parseResourceNamesFromFile(lockerServiceFileDescriptor); assertEquals(4, typeStringsToResourceNames.size()); @@ -81,7 +81,7 @@ public void parseResourceNames_basicTwoPatterns() { } @Test - public void parseResourceNames_wildcard() { + void parseResourceNames_wildcard() { Map typeStringsToResourceNames = ResourceNameParser.parseResourceNamesFromFile(lockerServiceFileDescriptor); assertEquals(4, typeStringsToResourceNames.size()); @@ -101,7 +101,7 @@ public void parseResourceNames_wildcard() { } @Test - public void parseResourceNames_deletedTopic() { + void parseResourceNames_deletedTopic() { Map typeStringsToResourceNames = ResourceNameParser.parseResourceNamesFromFile(lockerServiceFileDescriptor); assertEquals(4, typeStringsToResourceNames.size()); @@ -117,7 +117,7 @@ public void parseResourceNames_deletedTopic() { } @Test - public void parseResourceNames_messageResourceDefinition() { + void parseResourceNames_messageResourceDefinition() { String pakkage = TypeParser.getPackage(lockerServiceFileDescriptor); List messageDescriptors = lockerServiceFileDescriptor.getMessageTypes(); Map typeStringsToResourceNames = @@ -137,7 +137,7 @@ public void parseResourceNames_messageResourceDefinition() { } @Test - public void parseResourceNames_badMessageResourceNameDefinitionMissingNameField() { + void parseResourceNames_badMessageResourceNameDefinitionMissingNameField() { FileDescriptor protoFileDescriptor = BadMessageResnameDefProto.getDescriptor(); List messageDescriptors = protoFileDescriptor.getMessageTypes(); Descriptor messageDescriptor = messageDescriptors.get(0); @@ -149,7 +149,7 @@ public void parseResourceNames_badMessageResourceNameDefinitionMissingNameField( } @Test - public void parseResourceNameFromMessage_basicResourceDefinition() { + void parseResourceNameFromMessage_basicResourceDefinition() { String pakkage = TypeParser.getPackage(lockerServiceFileDescriptor); List messageDescriptors = lockerServiceFileDescriptor.getMessageTypes(); Descriptor documentMessageDescriptor = messageDescriptors.get(0); @@ -161,7 +161,7 @@ public void parseResourceNameFromMessage_basicResourceDefinition() { } @Test - public void parseResourceNamesFromMessage_noResourceDefinition() { + void parseResourceNamesFromMessage_noResourceDefinition() { String pakkage = TypeParser.getPackage(lockerServiceFileDescriptor); List messageDescriptors = lockerServiceFileDescriptor.getMessageTypes(); Descriptor folderMessageDescriptor = messageDescriptors.get(1); @@ -172,7 +172,7 @@ public void parseResourceNamesFromMessage_noResourceDefinition() { } @Test - public void parseResourceNameFromMessage_nonNameResourceReferenceField() { + void parseResourceNameFromMessage_nonNameResourceReferenceField() { String pakkage = TypeParser.getPackage(lockerServiceFileDescriptor); List messageDescriptors = lockerServiceFileDescriptor.getMessageTypes(); Descriptor binderMessageDescriptor = messageDescriptors.get(2); @@ -184,7 +184,7 @@ public void parseResourceNameFromMessage_nonNameResourceReferenceField() { } @Test - public void parseResourceNamesFromMessage_noNameOrResourceReferenceField() { + void parseResourceNamesFromMessage_noNameOrResourceReferenceField() { FileDescriptor protoFileDescriptor = BadMessageResnameDefProto.getDescriptor(); String pakkage = TypeParser.getPackage(protoFileDescriptor); List messageDescriptors = protoFileDescriptor.getMessageTypes(); @@ -197,14 +197,14 @@ public void parseResourceNamesFromMessage_noNameOrResourceReferenceField() { } @Test - public void getVariableName_basicPattern() { + void getVariableName_basicPattern() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern("projects/{project}"); assertTrue(nameOpt.isPresent()); assertEquals("project", nameOpt.get()); } @Test - public void getVariableName_basicPatternLonger() { + void getVariableName_basicPatternLonger() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern( "projects/{project}/billingAccounts/{billing_account}"); @@ -213,7 +213,7 @@ public void getVariableName_basicPatternLonger() { } @Test - public void getVariableName_differentCasedName() { + void getVariableName_differentCasedName() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern( "projects/{project}/billingAccounts/{billingAccOunt}"); @@ -222,7 +222,7 @@ public void getVariableName_differentCasedName() { } @Test - public void getVariableName_singletonEnding() { + void getVariableName_singletonEnding() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern("projects/{project}/cmekSettings"); assertTrue(nameOpt.isPresent()); @@ -230,7 +230,7 @@ public void getVariableName_singletonEnding() { } @Test - public void getVariableName_onlyLiterals() { + void getVariableName_onlyLiterals() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern("projects/project/locations/location"); assertTrue(nameOpt.isPresent()); @@ -238,7 +238,7 @@ public void getVariableName_onlyLiterals() { } @Test - public void getVariableName_deletedTopic() { + void getVariableName_deletedTopic() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern(ResourceNameConstants.DELETED_TOPIC_LITERAL); assertTrue(nameOpt.isPresent()); @@ -246,7 +246,7 @@ public void getVariableName_deletedTopic() { } @Test - public void getVariableName_wildcard() { + void getVariableName_wildcard() { Optional nameOpt = ResourceNameParser.getVariableNameFromPattern(ResourceNameConstants.WILDCARD_PATTERN); assertFalse(nameOpt.isPresent()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParserTest.java index b5f1725d4c..950a555587 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ResourceReferenceParserTest.java @@ -26,21 +26,21 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ResourceReferenceParserTest { +class ResourceReferenceParserTest { private static final String MAIN_PACKAGE = "com.google.testgapic.v1beta1"; private FileDescriptor lockerServiceFileDescriptor; - @Before - public void setUp() { + @BeforeEach + void setUp() { lockerServiceFileDescriptor = LockerProto.getDescriptor(); } @Test - public void parseParentResourceName_createFromPattern() { + void parseParentResourceName_createFromPattern() { String resourceNamePackage = String.format("%s.common", MAIN_PACKAGE); String domainName = "cloudbilling.googleapis.com"; String description = "This is the resource name description"; @@ -76,7 +76,7 @@ public void parseParentResourceName_createFromPattern() { } @Test - public void parseParentResourceName_parentResourceNameExists() { + void parseParentResourceName_parentResourceNameExists() { Map typeStringsToResourceNames = ResourceNameParser.parseResourceNamesFromFile(lockerServiceFileDescriptor); @@ -103,7 +103,7 @@ public void parseParentResourceName_parentResourceNameExists() { } @Test - public void parseParentResourceName_badPattern() { + void parseParentResourceName_badPattern() { Optional parentResourceNameOpt = ResourceReferenceParser.parseParentResourceName( "projects/{project}/billingAccounts", @@ -117,19 +117,19 @@ public void parseParentResourceName_badPattern() { } @Test - public void resolvePackages_resourcePackageIsSubpackageOfService() { + void resolvePackages_resourcePackageIsSubpackageOfService() { String resourcePackage = "com.google.testgapic.v1beta1.common"; assertEquals( resourcePackage, ResourceReferenceParser.resolvePackages(resourcePackage, MAIN_PACKAGE)); } @Test - public void resolvePackages_resourcePackageIsSameAsService() { + void resolvePackages_resourcePackageIsSameAsService() { assertEquals(MAIN_PACKAGE, ResourceReferenceParser.resolvePackages(MAIN_PACKAGE, MAIN_PACKAGE)); } @Test - public void resolvePackages_resourcePackageIsNotSubpackageOfService() { + void resolvePackages_resourcePackageIsNotSubpackageOfService() { assertEquals( MAIN_PACKAGE, ResourceReferenceParser.resolvePackages("com.google.cloud", MAIN_PACKAGE)); } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/RoutingRuleParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/RoutingRuleParserTest.java index 0908d79080..02e8bf1902 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/RoutingRuleParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/RoutingRuleParserTest.java @@ -25,9 +25,9 @@ import com.google.protobuf.Descriptors.MethodDescriptor; import com.google.protobuf.Descriptors.ServiceDescriptor; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class RoutingRuleParserTest { +class RoutingRuleParserTest { private static final FileDescriptor TESTING_FILE_DESCRIPTOR = RoutingRuleParserTestingOuterClass.getDescriptor(); @@ -35,13 +35,13 @@ public class RoutingRuleParserTest { TESTING_FILE_DESCRIPTOR.getServices().get(0); @Test - public void parse_shouldReturnNullRoutingHeadersIfMethodHasNoRoutingRules() { + void parse_shouldReturnNullRoutingHeadersIfMethodHasNoRoutingRules() { RoutingHeaderRule actual = getRoutingHeaders(0); assertThat(actual).isNull(); } @Test - public void parse_shouldSetPathTemplateToWildcardIfNotDefined() { + void parse_shouldSetPathTemplateToWildcardIfNotDefined() { RoutingHeaderRule actual = getRoutingHeaders(1); RoutingHeaderParam expected = RoutingHeaderParam.create("name", "name", String.format("{%s=**}", "name")); @@ -49,7 +49,7 @@ public void parse_shouldSetPathTemplateToWildcardIfNotDefined() { } @Test - public void parse_shouldThrowExceptionIfPathTemplateHasZeroNamedSegment() { + void parse_shouldThrowExceptionIfPathTemplateHasZeroNamedSegment() { IllegalArgumentException illegalArgumentException = assertThrows(IllegalArgumentException.class, () -> getRoutingHeaders(2)); assertThat(illegalArgumentException.getMessage()) @@ -60,7 +60,7 @@ public void parse_shouldThrowExceptionIfPathTemplateHasZeroNamedSegment() { } @Test - public void parse_shouldThrowExceptionIfPathTemplateHasMoreThanOneNamedSegment() { + void parse_shouldThrowExceptionIfPathTemplateHasMoreThanOneNamedSegment() { IllegalArgumentException illegalArgumentException = assertThrows(IllegalArgumentException.class, () -> getRoutingHeaders(3)); assertThat(illegalArgumentException.getMessage()) @@ -71,7 +71,7 @@ public void parse_shouldThrowExceptionIfPathTemplateHasMoreThanOneNamedSegment() } @Test - public void parse_shouldParseRoutingRulesWithOneParameter() { + void parse_shouldParseRoutingRulesWithOneParameter() { RoutingHeaderRule actual = getRoutingHeaders(4); RoutingHeaderParam expected = RoutingHeaderParam.create("name", "rename", "/v1beta1/{rename=tests/*}"); @@ -79,7 +79,7 @@ public void parse_shouldParseRoutingRulesWithOneParameter() { } @Test - public void parse_shouldParseRoutingRulesWithMultipleParameter() { + void parse_shouldParseRoutingRulesWithMultipleParameter() { RoutingHeaderRule actual = getRoutingHeaders(5); RoutingHeaderParam expectedHeader1 = RoutingHeaderParam.create("name", "rename", "/v1beta1/{rename=tests/*}"); @@ -91,7 +91,7 @@ public void parse_shouldParseRoutingRulesWithMultipleParameter() { } @Test - public void parse_shouldParseRoutingRulesWithNestedFields() { + void parse_shouldParseRoutingRulesWithNestedFields() { RoutingHeaderRule actual = getRoutingHeaders(6); RoutingHeaderParam expectedHeader1 = RoutingHeaderParam.create("account.name", "rename", "/v1beta1/{rename=tests/*}"); @@ -99,7 +99,7 @@ public void parse_shouldParseRoutingRulesWithNestedFields() { } @Test - public void parse_shouldThrowExceptionIfFieldValidationFailed() { + void parse_shouldThrowExceptionIfFieldValidationFailed() { assertThrows(Exception.class, () -> getRoutingHeaders(7)); } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceConfigParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceConfigParserTest.java index 8a27f7fd4f..80b28ed12c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceConfigParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceConfigParserTest.java @@ -25,15 +25,15 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceConfigParserTest { +class ServiceConfigParserTest { private static final String JSON_DIRECTORY = "src/test/resources/"; private static final double EPSILON = 1e-4; @Test - public void parseServiceConfig_basic() { + void parseServiceConfig_basic() { String jsonFilename = "retrying_grpc_service_config.json"; Path jsonPath = Paths.get(JSON_DIRECTORY, jsonFilename); Optional configOpt = ServiceConfigParser.parseFile(jsonPath.toString()); @@ -60,7 +60,7 @@ public void parseServiceConfig_basic() { } @Test - public void parseServiceConfig_showcase() { + void parseServiceConfig_showcase() { String jsonFilename = "showcase_grpc_service_config.json"; Path jsonPath = Paths.get(JSON_DIRECTORY, jsonFilename); Optional configOpt = ServiceConfigParser.parseFile(jsonPath.toString()); @@ -79,7 +79,7 @@ public void parseServiceConfig_showcase() { } @Test - public void parseBadServiceConfig_missingFile() { + void parseBadServiceConfig_missingFile() { String jsonFilename = "does_not_exist_grpc_service_config.json"; Path jsonPath = Paths.get(JSON_DIRECTORY, jsonFilename); Optional configOpt = ServiceConfigParser.parseFile(jsonPath.toString()); @@ -87,7 +87,7 @@ public void parseBadServiceConfig_missingFile() { } @Test - public void parseBadServiceConfig_malformedJson() { + void parseBadServiceConfig_malformedJson() { String jsonFilename = "malformed_grpc_service_config.json"; Path jsonPath = Paths.get(JSON_DIRECTORY, jsonFilename); Optional configOpt = ServiceConfigParser.parseFile(jsonPath.toString()); @@ -95,7 +95,7 @@ public void parseBadServiceConfig_malformedJson() { } @Test - public void parseBadServiceConfig_badProtoFields() { + void parseBadServiceConfig_badProtoFields() { String jsonFilename = "bad_proto_fields_grpc_service_config.json"; Path jsonPath = Paths.get(JSON_DIRECTORY, jsonFilename); Optional configOpt = ServiceConfigParser.parseFile(jsonPath.toString()); @@ -103,7 +103,7 @@ public void parseBadServiceConfig_badProtoFields() { } @Test - public void parseBadServiceConfig_nullOrEmptyPath() { + void parseBadServiceConfig_nullOrEmptyPath() { Optional configOpt = ServiceConfigParser.parseFile(null); assertFalse(configOpt.isPresent()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceYamlParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceYamlParserTest.java index 213b0abab8..a9270e2113 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceYamlParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ServiceYamlParserTest.java @@ -24,14 +24,14 @@ import java.nio.file.Paths; import java.util.List; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ServiceYamlParserTest { +class ServiceYamlParserTest { private static final String YAML_DIRECTORY = "src/test/resources/"; @Test - public void parseServiceYaml_basic() { + void parseServiceYaml_basic() { String yamlFilename = "logging.yaml"; Path yamlPath = Paths.get(YAML_DIRECTORY, yamlFilename); Optional serviceYamlProtoOpt = @@ -45,7 +45,7 @@ public void parseServiceYaml_basic() { // TODO: Add more scenarios (e.g. null MethodSettings, null PublishingSettings, incorrect // FieldNames, etc.) @Test - public void parseServiceYaml_autoPopulatedFields() { + void parseServiceYaml_autoPopulatedFields() { String yamlFilename = "auto_populate_field_testing.yaml"; Path yamlPath = Paths.get(YAML_DIRECTORY, yamlFilename); Optional serviceYamlProtoOpt = diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java index 40b9eb12f0..c9e40a8274 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/SourceCodeInfoParserTest.java @@ -32,10 +32,10 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class SourceCodeInfoParserTest { +class SourceCodeInfoParserTest { private static final String BASIC_PROTO = "basic.proto"; private static final String PROTO_DESCRIPTOR_SET = "test-proto.descriptorset"; @@ -43,14 +43,14 @@ public class SourceCodeInfoParserTest { private SourceCodeInfoParser parser; private FileDescriptor protoFile; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { parser = new SourceCodeInfoParser(); protoFile = buildFileDescriptor(); } @Test - public void getServiceInfo() { + void getServiceInfo() { SourceCodeInfoLocation location = parser.getLocation(protoFile.findServiceByName("FooService")); assertEquals( "This is a service description.\n It takes up multiple lines, like so.", @@ -61,7 +61,7 @@ public void getServiceInfo() { } @Test - public void getMethodInfo() { + void getMethodInfo() { ServiceDescriptor service = protoFile.findServiceByName("FooService"); SourceCodeInfoLocation location = parser.getLocation(service.findMethodByName("FooMethod")); assertEquals( @@ -74,7 +74,7 @@ public void getMethodInfo() { } @Test - public void getOuterMessageInfo() { + void getOuterMessageInfo() { Descriptor message = protoFile.findMessageTypeByName("FooMessage"); SourceCodeInfoLocation location = parser.getLocation(message); assertEquals( @@ -95,7 +95,7 @@ public void getOuterMessageInfo() { } @Test - public void getInnerMessageInfo() { + void getInnerMessageInfo() { Descriptor message = protoFile.findMessageTypeByName("FooMessage"); assertThat(message).isNotNull(); message = message.findNestedTypeByName("BarMessage"); @@ -113,7 +113,7 @@ public void getInnerMessageInfo() { } @Test - public void getOuterEnumInfo() { + void getOuterEnumInfo() { EnumDescriptor protoEnum = protoFile.findEnumTypeByName("OuterEnum"); SourceCodeInfoLocation location = parser.getLocation(protoEnum); assertEquals("This is an outer enum.", location.getLeadingComments()); @@ -124,7 +124,7 @@ public void getOuterEnumInfo() { } @Test - public void getInnerEnumInfo() { + void getInnerEnumInfo() { Descriptor message = protoFile.findMessageTypeByName("FooMessage"); EnumDescriptor protoEnum = message.findEnumTypeByName("FoodEnum"); SourceCodeInfoLocation location = parser.getLocation(protoEnum); @@ -138,7 +138,7 @@ public void getInnerEnumInfo() { } @Test - public void getOnoeofInfo() { + void getOnoeofInfo() { Descriptor message = protoFile.findMessageTypeByName("FooMessage"); OneofDescriptor protoOneof = message.getOneofs().get(0); SourceCodeInfoLocation location = parser.getLocation(protoOneof); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/TypeParserTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/TypeParserTest.java index 455f04bcae..aea2c9cfc1 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/TypeParserTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/TypeParserTest.java @@ -31,9 +31,9 @@ import com.google.test.collisions.CollisionsOuterClass; import com.google.testgapic.v1beta1.NestedMessageProto; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TypeParserTest { +class TypeParserTest { // TODO(miraleung): Backfill with more tests (e.g. field, message, methods) for Parser.java. private static final FileDescriptor COLLISIONS_FILE_DESCRIPTOR = @@ -46,7 +46,7 @@ public class TypeParserTest { COLLISIONS_FILE_DESCRIPTOR.getServices().get(0); @Test - public void parseMessageType_basic() { + void parseMessageType_basic() { FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor(); ServiceDescriptor echoService = echoFileDescriptor.getServices().get(0); assertEquals("Echo", echoService.getName()); @@ -57,7 +57,7 @@ public void parseMessageType_basic() { } @Test - public void parseMessageType_nested() { + void parseMessageType_nested() { FileDescriptor fileDescriptor = NestedMessageProto.getDescriptor(); Descriptor messageDescriptor = fileDescriptor.getMessageTypes().get(0); assertEquals("Outer", messageDescriptor.getName()); @@ -71,7 +71,7 @@ public void parseMessageType_nested() { } @Test - public void parseLroResponseMetadataType_shortName_shouldMatchSamePackage() { + void parseLroResponseMetadataType_shortName_shouldMatchSamePackage() { Map messageTypes = Parser.parseMessages(COLLISIONS_FILE_DESCRIPTOR); messageTypes.putAll(Parser.parseMessages(DESCRIPTOR_PROTOS_FILE_DESCRIPTOR)); messageTypes.putAll(Parser.parseMessages(LOCATION_PROTO_FILE_DESCRIPTOR)); @@ -97,7 +97,7 @@ public void parseLroResponseMetadataType_shortName_shouldMatchSamePackage() { } @Test - public void parseLroResponseMetadataType_shortName_shouldNotMatch() { + void parseLroResponseMetadataType_shortName_shouldNotMatch() { Map messageTypes = Parser.parseMessages(COLLISIONS_FILE_DESCRIPTOR); messageTypes.putAll(Parser.parseMessages(DESCRIPTOR_PROTOS_FILE_DESCRIPTOR)); MethodDescriptor shortNameMatchShouldThrowLro = COLLISIONS_SERVICE.getMethods().get(1); @@ -116,7 +116,7 @@ public void parseLroResponseMetadataType_shortName_shouldNotMatch() { } @Test - public void parseLroResponseMetadataType_shortName_withFullyQualifiedCollision() { + void parseLroResponseMetadataType_shortName_withFullyQualifiedCollision() { Map messageTypes = Parser.parseMessages(COLLISIONS_FILE_DESCRIPTOR); messageTypes.putAll(Parser.parseMessages(DESCRIPTOR_PROTOS_FILE_DESCRIPTOR)); messageTypes.putAll(Parser.parseMessages(LOCATION_PROTO_FILE_DESCRIPTOR)); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protowriter/WriterTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protowriter/WriterTest.java index bd7f475107..04d0dfa7de 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protowriter/WriterTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/protowriter/WriterTest.java @@ -12,42 +12,41 @@ import java.io.InputStreamReader; import java.io.Reader; import java.nio.file.Files; +import java.nio.file.Path; import java.util.Collections; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; -public class WriterTest { +class WriterTest { private static final TypeToken> REFLECT_CONFIG_JSON_FORMAT = new TypeToken>() {}; - @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); - + @TempDir Path tempDir; private JarOutputStream jarOutputStream; - private File file; - @Before - public void createJarOutputStream() throws IOException { - file = tempFolder.newFile("test.jar"); - jarOutputStream = new JarOutputStream(Files.newOutputStream(file.toPath())); + @BeforeEach + void createJarOutputStream() throws IOException { + Path path = tempDir.resolve("test.jar"); + jarOutputStream = new JarOutputStream(Files.newOutputStream(path)); + file = path.toFile(); } - @After - public void assertJarOutputStream_isClosed() { + @AfterEach + void assertJarOutputStream_isClosed() { assertThrows( IOException.class, () -> jarOutputStream.putNextEntry(new JarEntry("should.fail"))); } @Test - public void reflectConfig_notWritten_ifEmptyInput() throws IOException { + void reflectConfig_notWritten_ifEmptyInput() throws IOException { Writer.writeReflectConfigFile("com.google", Collections.emptyList(), jarOutputStream); jarOutputStream.finish(); @@ -60,7 +59,7 @@ public void reflectConfig_notWritten_ifEmptyInput() throws IOException { } @Test - public void reflectConfig_isWritten() throws IOException { + void reflectConfig_isWritten() throws IOException { Writer.writeReflectConfigFile( "com.google", Collections.singletonList(new ReflectConfig("com.google.Class")), diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/JavaStyleTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/JavaStyleTest.java index fec084555c..30b55801f7 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/JavaStyleTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/JavaStyleTest.java @@ -17,11 +17,11 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaStyleTest { +class JavaStyleTest { @Test - public void emptyOrNull() { + void emptyOrNull() { String value = ""; assertEquals("", JavaStyle.toLowerCamelCase(value)); assertEquals("", JavaStyle.toUpperCamelCase(value)); @@ -32,42 +32,42 @@ public void emptyOrNull() { } @Test - public void singleWord() { + void singleWord() { String value = "dog"; assertEquals("dog", JavaStyle.toLowerCamelCase(value)); assertEquals("Dog", JavaStyle.toUpperCamelCase(value)); } @Test - public void fromLowerSnake() { + void fromLowerSnake() { String value = "factory_decorator_delegate_impl"; assertEquals("factoryDecoratorDelegateImpl", JavaStyle.toLowerCamelCase(value)); assertEquals("FactoryDecoratorDelegateImpl", JavaStyle.toUpperCamelCase(value)); } @Test - public void fromUpperSnake() { + void fromUpperSnake() { String value = "FACTORY_DECORATOR_DELEGATE_IMPL"; assertEquals("factoryDecoratorDelegateImpl", JavaStyle.toLowerCamelCase(value)); assertEquals("FactoryDecoratorDelegateImpl", JavaStyle.toUpperCamelCase(value)); } @Test - public void fromLowerCamelCase() { + void fromLowerCamelCase() { String value = "factoryDecoratorDelegateImpl"; assertEquals("factoryDecoratorDelegateImpl", JavaStyle.toLowerCamelCase(value)); assertEquals("FactoryDecoratorDelegateImpl", JavaStyle.toUpperCamelCase(value)); } @Test - public void fromUpperCamelCase() { + void fromUpperCamelCase() { String value = "FactoryDecoratorDelegateImpl"; assertEquals("factoryDecoratorDelegateImpl", JavaStyle.toLowerCamelCase(value)); assertEquals("FactoryDecoratorDelegateImpl", JavaStyle.toUpperCamelCase(value)); } @Test - public void wordAndNumber() { + void wordAndNumber() { String value = "dog2"; assertEquals("dog2", JavaStyle.toLowerCamelCase(value)); assertEquals("Dog2", JavaStyle.toUpperCamelCase(value)); @@ -77,14 +77,14 @@ public void wordAndNumber() { } @Test - public void upperWordAndNumber() { + void upperWordAndNumber() { String value = "Dog_v2"; assertEquals("dogV2", JavaStyle.toLowerCamelCase(value)); assertEquals("DogV2", JavaStyle.toUpperCamelCase(value)); } @Test - public void upperWordAndCharsAfterDigit() { + void upperWordAndCharsAfterDigit() { String value = "dogV2cc"; assertEquals("dogV2Cc", JavaStyle.toLowerCamelCase(value)); assertEquals("DogV2Cc", JavaStyle.toUpperCamelCase(value)); @@ -103,7 +103,7 @@ public void upperWordAndCharsAfterDigit() { } @Test - public void acronyms() { + void acronyms() { String value = "iam_http_xml_dog"; assertEquals("iamHttpXmlDog", JavaStyle.toLowerCamelCase(value)); assertEquals("IamHttpXmlDog", JavaStyle.toUpperCamelCase(value)); @@ -113,7 +113,7 @@ public void acronyms() { } @Test - public void keyword() { + void keyword() { String value = "import"; assertEquals("import_", JavaStyle.toLowerCamelCase(value)); assertEquals("Import", JavaStyle.toUpperCamelCase(value)); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/ResourceReferenceUtilsTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/ResourceReferenceUtilsTest.java index 82147dcbf5..f640f6306b 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/ResourceReferenceUtilsTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/utils/ResourceReferenceUtilsTest.java @@ -19,47 +19,47 @@ import static org.junit.Assert.assertTrue; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ResourceReferenceUtilsTest { +class ResourceReferenceUtilsTest { @Test - public void parseParentPattern_basic() { + void parseParentPattern_basic() { String parentPattern = "projects/{project}"; String pattern = String.format("%s/folders/{folder}", parentPattern); assertEquals(parentPattern, ResourceReferenceUtils.parseParentPattern(pattern).get()); } @Test - public void parseParentPattern_wildcard() { + void parseParentPattern_wildcard() { Optional parentPatternOpt = ResourceReferenceUtils.parseParentPattern(ResourceNameConstants.WILDCARD_PATTERN); assertFalse(parentPatternOpt.isPresent()); } @Test - public void parseParentPattern_deletedTopicLiteral() { + void parseParentPattern_deletedTopicLiteral() { Optional parentPatternOpt = ResourceReferenceUtils.parseParentPattern(ResourceNameConstants.DELETED_TOPIC_LITERAL); assertFalse(parentPatternOpt.isPresent()); } @Test - public void parseParentPattern_noParents() { + void parseParentPattern_noParents() { Optional parentPatternOpt = ResourceReferenceUtils.parseParentPattern("projects/{project}"); assertFalse(parentPatternOpt.isPresent()); } @Test - public void parseParentPattern_insufficientPathComponents() { + void parseParentPattern_insufficientPathComponents() { Optional parentPatternOpt = ResourceReferenceUtils.parseParentPattern("projects/foobars/{foobar}"); assertFalse(parentPatternOpt.isPresent()); } @Test - public void parseParentPattern_lastComponentIsNotAVariable() { + void parseParentPattern_lastComponentIsNotAVariable() { Optional parentPatternOpt = ResourceReferenceUtils.parseParentPattern("projects/{project}/foobars"); assertTrue(parentPatternOpt.isPresent()); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/Differ.java b/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/Differ.java index eea5c7b937..4de2eff275 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/Differ.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/Differ.java @@ -23,10 +23,10 @@ import java.util.Arrays; import java.util.List; -public class Differ { +class Differ { private static final String LINE_SPLITTER = "\\r?\\n"; - public static List diff(Path goldenFilePath, String codegen) { + static List diff(Path goldenFilePath, String codegen) { List revised = Arrays.asList(codegen.split(LINE_SPLITTER)); List original = null; try { @@ -38,7 +38,7 @@ public static List diff(Path goldenFilePath, String codegen) { return diffTwoStringLists(original, revised); } - public static List diff(String expectedStr, String actualStr) { + static List diff(String expectedStr, String actualStr) { List revised = Arrays.asList(actualStr.split(LINE_SPLITTER)); List original = Arrays.asList(expectedStr.split(LINE_SPLITTER)); return diffTwoStringLists(original, revised); @@ -60,7 +60,7 @@ private static class GoldenFileReadException extends RuntimeException { private static final long serialVersionUID = 7423787084310530945L; - public GoldenFileReadException(String errorMessage, Throwable cause) { + GoldenFileReadException(String errorMessage, Throwable cause) { super(errorMessage, cause); } } @@ -69,7 +69,7 @@ private static class ComputeDiffException extends RuntimeException { private static final long serialVersionUID = -7480557222244987342L; - public ComputeDiffException(String errorMessage, Throwable cause) { + ComputeDiffException(String errorMessage, Throwable cause) { super(errorMessage, cause); } } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/SingleJUnitTestRunner.java b/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/SingleJUnitTestRunner.java index d5d3fb35fc..cfae012866 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/SingleJUnitTestRunner.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/test/framework/SingleJUnitTestRunner.java @@ -18,10 +18,10 @@ import org.junit.runner.Request; import org.junit.runner.Result; -public class SingleJUnitTestRunner { +class SingleJUnitTestRunner { // SingleJUnitTestRunner runs single JUnit test whose class name is passed through `args`. // This is used to prepare codegen for updating goldens files. - public static void main(String... args) { + static void main(String... args) { // Check whether the test class name is passed correctly e.g. // `com.google.api.generator.gapic.composer.ComposerTest` if (args.length < 1) { @@ -41,14 +41,14 @@ public static void main(String... args) { } } - public static class JUnitClassNotFoundException extends RuntimeException { - public JUnitClassNotFoundException(String errorMessage) { + static class JUnitClassNotFoundException extends RuntimeException { + JUnitClassNotFoundException(String errorMessage) { super(errorMessage); } } - public static class MissingRequiredArgException extends RuntimeException { - public MissingRequiredArgException(String errorMessage) { + static class MissingRequiredArgException extends RuntimeException { + MissingRequiredArgException(String errorMessage) { super(errorMessage); } } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/util/TrieTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/util/TrieTest.java index 874195d5f3..726c9a1d64 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/util/TrieTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/util/TrieTest.java @@ -23,11 +23,11 @@ import java.util.List; import java.util.function.BiFunction; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TrieTest { +class TrieTest { @Test - public void insertAndSearch_stringTrie() { + void insertAndSearch_stringTrie() { Trie trie = new Trie<>(); Function> wordToCharListFn = w -> Arrays.asList(w.split("(?!^)")); @@ -46,7 +46,7 @@ public void insertAndSearch_stringTrie() { } @Test - public void insertAndSearch_multiStringTrie() { + void insertAndSearch_multiStringTrie() { Trie trie = new Trie<>(); assertFalse(trie.search(Arrays.asList("user", "identity", "name"))); @@ -67,7 +67,7 @@ public void insertAndSearch_multiStringTrie() { } @Test - public void dfsTraverseAndReduce_emptyTrie() { + void dfsTraverseAndReduce_emptyTrie() { // Add up points in the tree, where each parent gets (num child node points) * 2 + 1. Function parentPreprocFn = nodeVal -> new Integer(0); BiFunction leafReduceFn = @@ -81,7 +81,7 @@ public void dfsTraverseAndReduce_emptyTrie() { } @Test - public void dfsTraverseAndReduce_singleNodeTrie() { + void dfsTraverseAndReduce_singleNodeTrie() { // Add up points in the tree, where each parent gets (num child node points) * 2 + 1. Function parentPreprocFn = nodeVal -> new Integer(0); BiFunction leafReduceFn = @@ -96,7 +96,7 @@ public void dfsTraverseAndReduce_singleNodeTrie() { } @Test - public void dfsTraverseAndReduce_oneParentOneChildBranchTrie() { + void dfsTraverseAndReduce_oneParentOneChildBranchTrie() { Function toUpperCaseFn = s -> s.substring(0, 1).toUpperCase() + s.substring(1); Function parentPreprocFn = nodeVal -> @@ -137,7 +137,7 @@ public void dfsTraverseAndReduce_oneParentOneChildBranchTrie() { } @Test - public void dfsTraverseAndReduce_oneDeepBranchTrie() { + void dfsTraverseAndReduce_oneDeepBranchTrie() { // Add up points in the tree, where each parent gets (num child node points) * 2 + 1. int simpleBaseValue = 0; Function simpleParentPreprocFn = nodeVal -> new Integer(0); @@ -195,7 +195,7 @@ public void dfsTraverseAndReduce_oneDeepBranchTrie() { } @Test - public void dfsTraverseAndReduce_depthAndBreathTrie() { + void dfsTraverseAndReduce_depthAndBreathTrie() { Function toUpperCaseFn = s -> s.substring(0, 1).toUpperCase() + s.substring(1); Function parentPreprocFn = nodeVal -> diff --git a/gax-java/dependencies.properties b/gax-java/dependencies.properties index 62e3702944..7ef2333875 100644 --- a/gax-java/dependencies.properties +++ b/gax-java/dependencies.properties @@ -79,9 +79,12 @@ maven.org_graalvm_sdk=org.graalvm.sdk:graal-sdk:22.3.5 # Testing maven artifacts maven.junit_junit=junit:junit:4.13.2 -maven.org_mockito_mockito_core=org.mockito:mockito-core:2.28.2 +maven.org_mockito_mockito_core=org.mockito:mockito-core:4.11.0 +maven.org_mockito_mockito_junit_jupiter=org.mockito:mockito-junit-jupiter:4.11.0 maven.org_hamcrest_hamcrest_core=org.hamcrest:hamcrest-core:1.3 maven.com_google_truth_truth=com.google.truth:truth:1.4.2 maven.com_googlecode_java_diff_utils_diffutils=com.googlecode.java-diff-utils:diffutils:1.3.0 -maven.net_bytebuddy_byte_buddy=net.bytebuddy:byte-buddy:1.14.15 +maven.net_bytebuddy_byte_buddy=net.bytebuddy:byte-buddy:1.14.16 maven.org_objenesis_objenesis=org.objenesis:objenesis:2.6 +maven.org_junit_jupiter_junit_jupiter_api=org.junit.jupiter:junit-jupiter-api:5.10.2 +maven.org_junit_jupiter_junit_jupiter_params=org.junit.jupiter:junit-jupiter-params:5.10.2 diff --git a/gax-java/gax-grpc/BUILD.bazel b/gax-java/gax-grpc/BUILD.bazel index f1dfe02fc6..be224ff3f8 100644 --- a/gax-java/gax-grpc/BUILD.bazel +++ b/gax-java/gax-grpc/BUILD.bazel @@ -35,8 +35,9 @@ _COMPILE_DEPS = [ ] _TEST_COMPILE_DEPS = [ - "@junit_junit//jar", + "@org_junit_jupiter_junit_jupiter_api//jar", "@org_mockito_mockito_core//jar", + "@org_mockito_mockito_junit_jupiter//jar", "@com_google_truth_truth//jar", "@io_grpc_grpc_java//core:inprocess", "@com_google_api_grpc_grpc_google_common_protos//jar", diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/CallOptionsUtilTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/CallOptionsUtilTest.java index 26a6b925f8..e9bba5d63d 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/CallOptionsUtilTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/CallOptionsUtilTest.java @@ -29,19 +29,20 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.common.collect.ImmutableMap; import io.grpc.CallOptions; import io.grpc.Metadata.Key; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CallOptionsUtilTest { +class CallOptionsUtilTest { @Test - public void testPutAndGetDynamicHeaderOption() { + void testPutAndGetDynamicHeaderOption() { String encodedRequestParams = "param1=value¶m2.param3=value23"; CallOptions options = CallOptionsUtil.putRequestParamsDynamicHeaderOption( @@ -54,7 +55,7 @@ public void testPutAndGetDynamicHeaderOption() { } @Test - public void testPutAndGetDynamicHeaderOptionEmpty() { + void testPutAndGetDynamicHeaderOptionEmpty() { CallOptions options = CallOptionsUtil.putRequestParamsDynamicHeaderOption(CallOptions.DEFAULT, ""); assertSame(CallOptions.DEFAULT, options); @@ -62,8 +63,10 @@ public void testPutAndGetDynamicHeaderOptionEmpty() { assertTrue(headers.isEmpty()); } - @Test(expected = NullPointerException.class) - public void testPutAndGetHeaderOptionNull() { - CallOptionsUtil.putRequestParamsDynamicHeaderOption(CallOptions.DEFAULT, null); + @Test + void testPutAndGetHeaderOptionNull() { + assertThrows( + NullPointerException.class, + () -> CallOptionsUtil.putRequestParamsDynamicHeaderOption(CallOptions.DEFAULT, null)); } } diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ChannelPoolTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ChannelPoolTest.java index ebc941ec0a..b9d6ae6c6d 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ChannelPoolTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ChannelPoolTest.java @@ -69,29 +69,26 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -@RunWith(JUnit4.class) -public class ChannelPoolTest { +class ChannelPoolTest { private static final int DEFAULT_AWAIT_TERMINATION_SEC = 10; private ChannelPool pool; - @After - public void cleanup() throws InterruptedException { + @AfterEach + void cleanup() throws InterruptedException { Preconditions.checkNotNull(pool, "Channel pool was never created"); pool.shutdown(); pool.awaitTermination(DEFAULT_AWAIT_TERMINATION_SEC, TimeUnit.SECONDS); } @Test - public void testAuthority() throws IOException { + void testAuthority() throws IOException { ManagedChannel sub1 = Mockito.mock(ManagedChannel.class); ManagedChannel sub2 = Mockito.mock(ManagedChannel.class); @@ -105,7 +102,7 @@ public void testAuthority() throws IOException { } @Test - public void testRoundRobin() throws IOException { + void testRoundRobin() throws IOException { ManagedChannel sub1 = Mockito.mock(ManagedChannel.class); ManagedChannel sub2 = Mockito.mock(ManagedChannel.class); @@ -144,7 +141,7 @@ private void verifyTargetChannel( } @Test - public void ensureEvenDistribution() throws InterruptedException, IOException { + void ensureEvenDistribution() throws InterruptedException, IOException { int numChannels = 10; final ManagedChannel[] channels = new ManagedChannel[numChannels]; final AtomicInteger[] counts = new AtomicInteger[numChannels]; @@ -197,7 +194,7 @@ public void ensureEvenDistribution() throws InterruptedException, IOException { // Test channelPrimer is called same number of times as poolSize if executorService is set to null @Test - public void channelPrimerShouldCallPoolConstruction() throws IOException { + void channelPrimerShouldCallPoolConstruction() throws IOException { ChannelPrimer mockChannelPrimer = Mockito.mock(ChannelPrimer.class); ManagedChannel channel1 = Mockito.mock(ManagedChannel.class); ManagedChannel channel2 = Mockito.mock(ManagedChannel.class); @@ -215,7 +212,7 @@ public void channelPrimerShouldCallPoolConstruction() throws IOException { // Test channelPrimer is called periodically, if there's an executorService @Test - public void channelPrimerIsCalledPeriodically() throws IOException { + void channelPrimerIsCalledPeriodically() throws IOException { ChannelPrimer mockChannelPrimer = Mockito.mock(ChannelPrimer.class); ManagedChannel channel1 = Mockito.mock(ManagedChannel.class); ManagedChannel channel2 = Mockito.mock(ManagedChannel.class); @@ -266,7 +263,7 @@ public void channelPrimerIsCalledPeriodically() throws IOException { // ---- // call should be allowed to complete and the channel should not be shutdown @Test - public void callShouldCompleteAfterCreation() throws IOException { + void callShouldCompleteAfterCreation() throws IOException { ManagedChannel underlyingChannel = Mockito.mock(ManagedChannel.class); ManagedChannel replacementChannel = Mockito.mock(ManagedChannel.class); FakeChannelFactory channelFactory = @@ -314,7 +311,7 @@ public void callShouldCompleteAfterCreation() throws IOException { // call should be allowed to complete and the channel should not be shutdown @Test - public void callShouldCompleteAfterStarted() throws IOException { + void callShouldCompleteAfterStarted() throws IOException { final ManagedChannel underlyingChannel = Mockito.mock(ManagedChannel.class); ManagedChannel replacementChannel = Mockito.mock(ManagedChannel.class); @@ -359,7 +356,7 @@ public void callShouldCompleteAfterStarted() throws IOException { // Channel should be shutdown after a refresh all the calls have completed @Test - public void channelShouldShutdown() throws IOException { + void channelShouldShutdown() throws IOException { ManagedChannel underlyingChannel = Mockito.mock(ManagedChannel.class); ManagedChannel replacementChannel = Mockito.mock(ManagedChannel.class); @@ -402,7 +399,7 @@ public void channelShouldShutdown() throws IOException { } @Test - public void channelRefreshShouldSwapChannels() throws IOException { + void channelRefreshShouldSwapChannels() throws IOException { ManagedChannel underlyingChannel1 = Mockito.mock(ManagedChannel.class); ManagedChannel underlyingChannel2 = Mockito.mock(ManagedChannel.class); @@ -442,7 +439,7 @@ public void channelRefreshShouldSwapChannels() throws IOException { } @Test - public void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits() throws Exception { + void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits() throws Exception { ScheduledExecutorService executor = Mockito.mock(ScheduledExecutorService.class); List channels = new ArrayList<>(); @@ -521,7 +518,7 @@ public void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits() thro } @Test - public void removedIdleChannelsAreShutdown() throws Exception { + void removedIdleChannelsAreShutdown() throws Exception { ScheduledExecutorService executor = Mockito.mock(ScheduledExecutorService.class); List channels = new ArrayList<>(); @@ -561,7 +558,7 @@ public void removedIdleChannelsAreShutdown() throws Exception { } @Test - public void removedActiveChannelsAreShutdown() throws Exception { + void removedActiveChannelsAreShutdown() throws Exception { ScheduledExecutorService executor = Mockito.mock(ScheduledExecutorService.class); List channels = new ArrayList<>(); @@ -622,7 +619,7 @@ public void removedActiveChannelsAreShutdown() throws Exception { } @Test - public void testReleasingClientCallCancelEarly() throws IOException { + void testReleasingClientCallCancelEarly() throws IOException { ClientCall mockClientCall = Mockito.mock(ClientCall.class); Mockito.doAnswer(invocation -> null).when(mockClientCall).cancel(Mockito.any(), Mockito.any()); ManagedChannel fakeChannel = Mockito.mock(ManagedChannel.class); @@ -650,7 +647,7 @@ public void testReleasingClientCallCancelEarly() throws IOException { Color request = Color.newBuilder().setRed(0.5f).build(); IllegalStateException e = - Assert.assertThrows( + Assertions.assertThrows( IllegalStateException.class, () -> streamingCallable.call( @@ -675,7 +672,7 @@ public void onComplete() {} } @Test - public void testDoubleRelease() throws Exception { + void testDoubleRelease() throws Exception { FakeLogHandler logHandler = new FakeLogHandler(); ChannelPool.LOG.addHandler(logHandler); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GaxGrpcPropertiesTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GaxGrpcPropertiesTest.java index 4174312272..651b17e712 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GaxGrpcPropertiesTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GaxGrpcPropertiesTest.java @@ -29,31 +29,28 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.regex.Pattern; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) -public class GaxGrpcPropertiesTest { +class GaxGrpcPropertiesTest { @Test - public void testGrpcVersion() { + void testGrpcVersion() { String grpcVersion = GaxGrpcProperties.getGrpcVersion(); assertTrue(Pattern.compile("^\\d+\\.\\d+\\.\\d+").matcher(grpcVersion).find()); } @Test - public void testGaxGrpcVersion() { + void testGaxGrpcVersion() { String gaxGrpcVersion = GaxGrpcProperties.getGaxGrpcVersion(); assertNotNull(gaxGrpcVersion); } @Test - public void testDefaultHeaderPattern() { + void testDefaultHeaderPattern() { assertTrue( GaxGrpcProperties.getDefaultApiClientHeaderPattern() .matcher("gl-java/1.8_00 gapic/1.2.3-alpha gax/1.5.0 grpc/1.7.0") diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcApiExceptionFactoryTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcApiExceptionFactoryTest.java index bb8febef54..e4e86d589d 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcApiExceptionFactoryTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcApiExceptionFactoryTest.java @@ -44,13 +44,10 @@ import io.grpc.StatusException; import io.grpc.StatusRuntimeException; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) -public class GrpcApiExceptionFactoryTest { +class GrpcApiExceptionFactoryTest { private static final ErrorInfo ERROR_INFO = ErrorInfo.newBuilder() @@ -72,13 +69,13 @@ public class GrpcApiExceptionFactoryTest { private GrpcApiExceptionFactory factory; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { factory = new GrpcApiExceptionFactory(Collections.emptySet()); } @Test - public void create_shouldCreateApiExceptionWithErrorDetailsForStatusException() { + void create_shouldCreateApiExceptionWithErrorDetailsForStatusException() { Metadata trailers = new Metadata(); Status status = Status.newBuilder().addAllDetails(RAW_ERROR_MESSAGES).build(); trailers.put( @@ -91,7 +88,7 @@ public void create_shouldCreateApiExceptionWithErrorDetailsForStatusException() } @Test - public void create_shouldCreateApiExceptionWithErrorDetailsForStatusRuntimeException() { + void create_shouldCreateApiExceptionWithErrorDetailsForStatusRuntimeException() { Metadata trailers = new Metadata(); Status status = Status.newBuilder().addAllDetails(RAW_ERROR_MESSAGES).build(); trailers.put( @@ -104,7 +101,7 @@ public void create_shouldCreateApiExceptionWithErrorDetailsForStatusRuntimeExcep } @Test - public void create_shouldCreateApiExceptionWithNoErrorDetailsIfMetadataIsNull() { + void create_shouldCreateApiExceptionWithNoErrorDetailsIfMetadataIsNull() { StatusRuntimeException statusException = new StatusRuntimeException(GRPC_STATUS, null); ApiException actual = factory.create(statusException); @@ -113,7 +110,7 @@ public void create_shouldCreateApiExceptionWithNoErrorDetailsIfMetadataIsNull() } @Test - public void create_shouldCreateApiExceptionWithNoErrorDetailsIfMetadataDoesNotHaveErrorDetails() { + void create_shouldCreateApiExceptionWithNoErrorDetailsIfMetadataDoesNotHaveErrorDetails() { StatusRuntimeException statusException = new StatusRuntimeException(GRPC_STATUS, new Metadata()); @@ -123,7 +120,7 @@ public void create_shouldCreateApiExceptionWithNoErrorDetailsIfMetadataDoesNotHa } @Test - public void create_shouldCreateApiExceptionWithNoErrorDetailsIfStatusIsMalformed() { + void create_shouldCreateApiExceptionWithNoErrorDetailsIfStatusIsMalformed() { Metadata trailers = new Metadata(); Status status = Status.newBuilder().addDetails(Any.pack(ERROR_INFO)).build(); byte[] bytes = status.toByteArray(); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallContextTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallContextTest.java index e67c4c13c2..02d922c635 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallContextTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallContextTest.java @@ -29,9 +29,9 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; @@ -53,21 +53,18 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class GrpcCallContextTest { +class GrpcCallContextTest { @Test - public void testNullToSelfWrongType() { + void testNullToSelfWrongType() { try { GrpcCallContext.createDefault().nullToSelf(FakeCallContext.createDefault()); - Assert.fail("GrpcCallContext should have thrown an exception"); + Assertions.fail("GrpcCallContext should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected) .hasMessageThat() @@ -76,7 +73,7 @@ public void testNullToSelfWrongType() { } @Test - public void testWithCredentials() { + void testWithCredentials() { Credentials credentials = Mockito.mock(Credentials.class); GrpcCallContext emptyContext = GrpcCallContext.createDefault(); assertNull(emptyContext.getCallOptions().getCredentials()); @@ -85,7 +82,7 @@ public void testWithCredentials() { } @Test - public void testWithTransportChannel() { + void testWithTransportChannel() { ManagedChannel channel = Mockito.mock(ManagedChannel.class); GrpcCallContext context = GrpcCallContext.createDefault().withTransportChannel(GrpcTransportChannel.create(channel)); @@ -93,21 +90,21 @@ public void testWithTransportChannel() { } @Test - public void testWithTransportChannelWrongType() { + void testWithTransportChannelWrongType() { FakeChannel channel = new FakeChannel(); try { GrpcCallContext.createDefault().withTransportChannel(FakeTransportChannel.create(channel)); - Assert.fail("GrpcCallContext should have thrown an exception"); + Assertions.fail("GrpcCallContext should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected).hasMessageThat().contains("Expected GrpcTransportChannel"); } } @Test - public void testMergeWrongType() { + void testMergeWrongType() { try { GrpcCallContext.createDefault().merge(FakeCallContext.createDefault()); - Assert.fail("GrpcCallContext should have thrown an exception"); + Assertions.fail("GrpcCallContext should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected) .hasMessageThat() @@ -116,7 +113,7 @@ public void testMergeWrongType() { } @Test - public void testWithRequestParamsDynamicHeaderOption() { + void testWithRequestParamsDynamicHeaderOption() { String encodedRequestParams = "param1=value¶m2.param3=value23"; GrpcCallContext context = GrpcCallContext.createDefault().withRequestParamsDynamicHeaderOption(encodedRequestParams); @@ -129,22 +126,22 @@ public void testWithRequestParamsDynamicHeaderOption() { } @Test - public void testWithTimeout() { + void testWithTimeout() { assertNull(GrpcCallContext.createDefault().withTimeout(null).getTimeout()); } @Test - public void testWithNegativeTimeout() { + void testWithNegativeTimeout() { assertNull(GrpcCallContext.createDefault().withTimeout(Duration.ofSeconds(-1L)).getTimeout()); } @Test - public void testWithZeroTimeout() { + void testWithZeroTimeout() { assertNull(GrpcCallContext.createDefault().withTimeout(Duration.ofSeconds(0L)).getTimeout()); } @Test - public void testWithShorterTimeout() { + void testWithShorterTimeout() { GrpcCallContext ctxWithLongTimeout = GrpcCallContext.createDefault().withTimeout(Duration.ofSeconds(10)); @@ -157,7 +154,7 @@ public void testWithShorterTimeout() { } @Test - public void testWithLongerTimeout() { + void testWithLongerTimeout() { GrpcCallContext ctxWithShortTimeout = GrpcCallContext.createDefault().withTimeout(Duration.ofSeconds(5)); @@ -171,7 +168,7 @@ public void testWithLongerTimeout() { } @Test - public void testMergeWithNullTimeout() { + void testMergeWithNullTimeout() { Duration timeout = Duration.ofSeconds(10); GrpcCallContext baseContext = GrpcCallContext.createDefault().withTimeout(timeout); @@ -183,7 +180,7 @@ public void testMergeWithNullTimeout() { } @Test - public void testMergeWithTimeout() { + void testMergeWithTimeout() { Duration timeout = Duration.ofSeconds(19); GrpcCallContext ctx1 = GrpcCallContext.createDefault(); GrpcCallContext ctx2 = GrpcCallContext.createDefault().withTimeout(timeout); @@ -192,14 +189,14 @@ public void testMergeWithTimeout() { } @Test - public void testWithStreamingWaitTimeout() { + void testWithStreamingWaitTimeout() { Duration timeout = Duration.ofSeconds(15); GrpcCallContext context = GrpcCallContext.createDefault().withStreamWaitTimeout(timeout); Truth.assertThat(context.getStreamWaitTimeout()).isEqualTo(timeout); } @Test - public void testMergeWithNullStreamingWaitTimeout() { + void testMergeWithNullStreamingWaitTimeout() { Duration timeout = Duration.ofSeconds(10); GrpcCallContext baseContext = GrpcCallContext.createDefault().withStreamWaitTimeout(timeout); @@ -213,7 +210,7 @@ public void testMergeWithNullStreamingWaitTimeout() { } @Test - public void testWithZeroStreamingWaitTimeout() { + void testWithZeroStreamingWaitTimeout() { Duration timeout = Duration.ZERO; Truth.assertThat( GrpcCallContext.createDefault().withStreamWaitTimeout(timeout).getStreamWaitTimeout()) @@ -221,7 +218,7 @@ public void testWithZeroStreamingWaitTimeout() { } @Test - public void testMergeWithStreamingWaitTimeout() { + void testMergeWithStreamingWaitTimeout() { Duration timeout = Duration.ofSeconds(19); GrpcCallContext ctx1 = GrpcCallContext.createDefault(); GrpcCallContext ctx2 = GrpcCallContext.createDefault().withStreamWaitTimeout(timeout); @@ -230,14 +227,14 @@ public void testMergeWithStreamingWaitTimeout() { } @Test - public void testWithStreamingIdleTimeout() { + void testWithStreamingIdleTimeout() { Duration timeout = Duration.ofSeconds(15); GrpcCallContext context = GrpcCallContext.createDefault().withStreamIdleTimeout(timeout); Truth.assertThat(context.getStreamIdleTimeout()).isEqualTo(timeout); } @Test - public void testMergeWithNullStreamingIdleTimeout() { + void testMergeWithNullStreamingIdleTimeout() { Duration timeout = Duration.ofSeconds(10); GrpcCallContext baseContext = GrpcCallContext.createDefault().withStreamIdleTimeout(timeout); @@ -251,7 +248,7 @@ public void testMergeWithNullStreamingIdleTimeout() { } @Test - public void testWithZeroStreamingIdleTimeout() { + void testWithZeroStreamingIdleTimeout() { Duration timeout = Duration.ZERO; Truth.assertThat( GrpcCallContext.createDefault().withStreamIdleTimeout(timeout).getStreamIdleTimeout()) @@ -259,7 +256,7 @@ public void testWithZeroStreamingIdleTimeout() { } @Test - public void testMergeWithStreamingIdleTimeout() { + void testMergeWithStreamingIdleTimeout() { Duration timeout = Duration.ofSeconds(19); GrpcCallContext ctx1 = GrpcCallContext.createDefault(); GrpcCallContext ctx2 = GrpcCallContext.createDefault().withStreamIdleTimeout(timeout); @@ -268,7 +265,7 @@ public void testMergeWithStreamingIdleTimeout() { } @Test - public void testMergeWithCustomCallOptions() { + void testMergeWithCustomCallOptions() { CallOptions.Key key = CallOptions.Key.createWithDefault("somekey", "somedefault"); GrpcCallContext ctx1 = GrpcCallContext.createDefault(); GrpcCallContext ctx2 = @@ -283,7 +280,7 @@ public void testMergeWithCustomCallOptions() { } @Test - public void testWithExtraHeaders() { + void testWithExtraHeaders() { Map> extraHeaders = createTestExtraHeaders("key1", "value1", "key1", "value2"); GrpcCallContext ctx = GrpcCallContext.createDefault().withExtraHeaders(extraHeaders); @@ -298,7 +295,7 @@ public void testWithExtraHeaders() { } @Test - public void testMergeWithExtraHeaders() { + void testMergeWithExtraHeaders() { Map> extraHeaders1 = createTestExtraHeaders("key1", "value1", "key1", "value2"); GrpcCallContext ctx1 = GrpcCallContext.createDefault().withExtraHeaders(extraHeaders1); @@ -316,7 +313,7 @@ public void testMergeWithExtraHeaders() { } @Test - public void testMergeWithTracer() { + void testMergeWithTracer() { ApiTracer explicitTracer = Mockito.mock(ApiTracer.class); GrpcCallContext ctxWithExplicitTracer = GrpcCallContext.createDefault().withTracer(explicitTracer); @@ -338,7 +335,7 @@ public void testMergeWithTracer() { } @Test - public void testWithRetrySettings() { + void testWithRetrySettings() { RetrySettings retrySettings = Mockito.mock(RetrySettings.class); GrpcCallContext emptyContext = GrpcCallContext.createDefault(); assertNull(emptyContext.getRetrySettings()); @@ -347,7 +344,7 @@ public void testWithRetrySettings() { } @Test - public void testWithRetryableCodes() { + void testWithRetryableCodes() { Set codes = Collections.singleton(StatusCode.Code.UNAVAILABLE); GrpcCallContext emptyContext = GrpcCallContext.createDefault(); assertNull(emptyContext.getRetryableCodes()); @@ -356,7 +353,7 @@ public void testWithRetryableCodes() { } @Test - public void testWithOptions() { + void testWithOptions() { GrpcCallContext emptyCallContext = GrpcCallContext.createDefault(); ApiCallContext.Key contextKey1 = ApiCallContext.Key.create("testKey1"); ApiCallContext.Key contextKey2 = ApiCallContext.Key.create("testKey2"); @@ -374,7 +371,7 @@ public void testWithOptions() { } @Test - public void testMergeOptions() throws IOException { + void testMergeOptions() throws IOException { GrpcCallContext emptyCallContext = GrpcCallContext.createDefault(); ApiCallContext.Key contextKey1 = ApiCallContext.Key.create("testKey1"); ApiCallContext.Key contextKey2 = ApiCallContext.Key.create("testKey2"); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallableFactoryTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallableFactoryTest.java index a274512e14..a24e777774 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallableFactoryTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcCallableFactoryTest.java @@ -55,22 +55,19 @@ import io.grpc.MethodDescriptor.MethodType; import io.grpc.inprocess.InProcessChannelBuilder; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class GrpcCallableFactoryTest { +class GrpcCallableFactoryTest { private InProcessServer inprocessServer; private ManagedChannel channel; private ClientContext clientContext; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { String serverName = "fakeservice"; FakeServiceImpl serviceImpl = new FakeServiceImpl(); inprocessServer = new InProcessServer<>(serviceImpl, serverName); @@ -90,14 +87,14 @@ public void setUp() throws Exception { .build(); } - @After - public void tearDown() { + @AfterEach + void tearDown() { channel.shutdown(); inprocessServer.stop(); } @Test - public void createServerStreamingCallableRetryableExceptions() { + void createServerStreamingCallableRetryableExceptions() { GrpcCallSettings grpcCallSettings = GrpcCallSettings.create(FakeServiceGrpc.METHOD_STREAMING_RECOGNIZE_ERROR); @@ -151,7 +148,7 @@ public void createServerStreamingCallableRetryableExceptions() { } @Test - public void testGetSpanName() { + void testGetSpanName() { @SuppressWarnings("unchecked") MethodDescriptor descriptor = MethodDescriptor.newBuilder() @@ -166,7 +163,7 @@ public void testGetSpanName() { } @Test - public void testGetSpanNameUnqualified() { + void testGetSpanNameUnqualified() { @SuppressWarnings("unchecked") MethodDescriptor descriptor = MethodDescriptor.newBuilder() @@ -181,7 +178,7 @@ public void testGetSpanNameUnqualified() { } @Test - public void testGetSpanNameInvalid() { + void testGetSpanNameInvalid() { List invalidNames = ImmutableList.of("BareMethod", "/MethodWithoutService"); for (String invalidName : invalidNames) { diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcClientCallsTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcClientCallsTest.java index eb9277b2e1..a22b5fa747 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcClientCallsTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcClientCallsTest.java @@ -30,7 +30,7 @@ package com.google.api.gax.grpc; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.verify; import com.google.api.gax.grpc.testing.FakeChannelFactory; @@ -58,13 +58,13 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.threeten.bp.Duration; -public class GrpcClientCallsTest { +class GrpcClientCallsTest { // Auth Library's GoogleAuthException is package-private. Copy basic functionality for tests private static class GoogleAuthException extends IOException implements Retryable { @@ -91,8 +91,8 @@ public int getRetryCount() { private Credentials credentials; private Channel mockChannel; - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { credentials = Mockito.mock(Credentials.class); endpointContext = Mockito.mock(EndpointContext.class); mockChannel = Mockito.mock(Channel.class); @@ -104,7 +104,7 @@ public void setUp() throws IOException { } @Test - public void testAffinity() throws IOException { + void testAffinity() throws IOException { MethodDescriptor descriptor = FakeServiceGrpc.METHOD_RECOGNIZE; @SuppressWarnings("unchecked") @@ -138,7 +138,7 @@ public void testAffinity() throws IOException { } @Test - public void testExtraHeaders() throws IOException { + void testExtraHeaders() throws IOException { Metadata emptyHeaders = new Metadata(); final Map> extraHeaders = new HashMap<>(); extraHeaders.put( @@ -179,7 +179,7 @@ public void testExtraHeaders() throws IOException { } @Test - public void testTimeoutToDeadlineConversion() throws IOException { + void testTimeoutToDeadlineConversion() throws IOException { MethodDescriptor descriptor = FakeServiceGrpc.METHOD_RECOGNIZE; @SuppressWarnings("unchecked") @@ -209,7 +209,7 @@ public void testTimeoutToDeadlineConversion() throws IOException { } @Test - public void testTimeoutAfterDeadline() throws IOException { + void testTimeoutAfterDeadline() throws IOException { MethodDescriptor descriptor = FakeServiceGrpc.METHOD_RECOGNIZE; @SuppressWarnings("unchecked") @@ -242,7 +242,7 @@ public void testTimeoutAfterDeadline() throws IOException { } @Test - public void testTimeoutBeforeDeadline() throws IOException { + void testTimeoutBeforeDeadline() throws IOException { MethodDescriptor descriptor = FakeServiceGrpc.METHOD_RECOGNIZE; @SuppressWarnings("unchecked") @@ -279,7 +279,7 @@ public void testTimeoutBeforeDeadline() throws IOException { } @Test - public void testValidUniverseDomain() throws IOException { + void testValidUniverseDomain() throws IOException { GrpcCallContext context = GrpcCallContext.createDefault() .withChannel(mockChannel) @@ -295,7 +295,7 @@ public void testValidUniverseDomain() throws IOException { // This test is when the universe domain does not match @Test - public void testInvalidUniverseDomain() throws IOException { + void testInvalidUniverseDomain() throws IOException { Mockito.doThrow( new UnauthenticatedException( null, GrpcStatusCode.of(Status.Code.UNAUTHENTICATED), false)) @@ -319,7 +319,7 @@ public void testInvalidUniverseDomain() throws IOException { // This test is when the MDS is unable to return a valid universe domain @Test - public void testUniverseDomainNotReady_shouldRetry() throws IOException { + void testUniverseDomainNotReady_shouldRetry() throws IOException { Mockito.doThrow(new GoogleAuthException(true)) .when(endpointContext) .validateUniverseDomain(Mockito.any(Credentials.class), Mockito.any(GrpcStatusCode.class)); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectServerStreamingCallableTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectServerStreamingCallableTest.java index 5935d1d786..843ae84331 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectServerStreamingCallableTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectServerStreamingCallableTest.java @@ -59,16 +59,13 @@ import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -@RunWith(JUnit4.class) -public class GrpcDirectServerStreamingCallableTest { +class GrpcDirectServerStreamingCallableTest { private static final Color DEFAULT_REQUEST = Color.newBuilder().setRed(0.5f).build(); private static final Color ASYNC_REQUEST = DEFAULT_REQUEST.toBuilder().setGreen(1000).build(); private static final Color ERROR_REQUEST = Color.newBuilder().setRed(-1).build(); @@ -81,8 +78,8 @@ public class GrpcDirectServerStreamingCallableTest { private ServerStreamingCallSettings streamingCallSettings; private ServerStreamingCallable streamingCallable; - @Before - public void setUp() throws InstantiationException, IllegalAccessException, IOException { + @BeforeEach + void setUp() throws InstantiationException, IllegalAccessException, IOException { String serverName = "fakeservice"; FakeServiceImpl serviceImpl = new FakeServiceImpl(); inprocessServer = new InProcessServer<>(serviceImpl, serverName); @@ -109,14 +106,14 @@ public void setUp() throws InstantiationException, IllegalAccessException, IOExc clientContext); } - @After - public void tearDown() { + @AfterEach + void tearDown() { channel.shutdown(); inprocessServer.stop(); } @Test - public void testBadContext() { + void testBadContext() { streamingCallable = GrpcCallableFactory.createServerStreamingCallable( GrpcCallSettings.create(METHOD_SERVER_STREAMING_RECOGNIZE), @@ -130,7 +127,7 @@ public void testBadContext() { MoneyObserver observer = new MoneyObserver(true, latch); try { streamingCallable.call(DEFAULT_REQUEST, observer); - Assert.fail("Callable should have thrown an exception"); + Assertions.fail("Callable should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected) .hasMessageThat() @@ -139,7 +136,7 @@ public void testBadContext() { } @Test - public void testServerStreamingStart() { + void testServerStreamingStart() { CountDownLatch latch = new CountDownLatch(1); MoneyObserver moneyObserver = new MoneyObserver(true, latch); @@ -149,7 +146,7 @@ public void testServerStreamingStart() { } @Test - public void testServerStreaming() throws Exception { + void testServerStreaming() throws Exception { CountDownLatch latch = new CountDownLatch(2); MoneyObserver moneyObserver = new MoneyObserver(true, latch); @@ -161,7 +158,7 @@ public void testServerStreaming() throws Exception { } @Test - public void testManualFlowControl() throws Exception { + void testManualFlowControl() throws Exception { CountDownLatch latch = new CountDownLatch(2); MoneyObserver moneyObserver = new MoneyObserver(false, latch); @@ -180,7 +177,7 @@ public void testManualFlowControl() throws Exception { } @Test - public void testCancelClientCall() throws Exception { + void testCancelClientCall() throws Exception { CountDownLatch latch = new CountDownLatch(1); MoneyObserver moneyObserver = new MoneyObserver(false, latch); @@ -195,7 +192,7 @@ public void testCancelClientCall() throws Exception { } @Test - public void testOnResponseError() throws Throwable { + void testOnResponseError() throws Throwable { CountDownLatch latch = new CountDownLatch(1); MoneyObserver moneyObserver = new MoneyObserver(true, latch); @@ -211,7 +208,7 @@ public void testOnResponseError() throws Throwable { } @Test - public void testObserverErrorCancelsCall() throws Throwable { + void testObserverErrorCancelsCall() throws Throwable { final RuntimeException expectedCause = new RuntimeException("some error"); final SettableApiFuture actualErrorF = SettableApiFuture.create(); @@ -250,7 +247,7 @@ protected void onCompleteImpl() { } @Test - public void testBlockingServerStreaming() { + void testBlockingServerStreaming() { Color request = Color.newBuilder().setRed(0.5f).build(); ServerStream response = streamingCallable.call(request); List responseData = Lists.newArrayList(response); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java index 96d7cf1063..64d908de28 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamControllerTest.java @@ -54,17 +54,16 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class GrpcDirectStreamControllerTest { +class GrpcDirectStreamControllerTest { private static final int DEFAULT_AWAIT_TERMINATION_SEC = 10; - @Test(timeout = 180_000) // ms - public void testRetryNoRaceCondition() throws Exception { + @Test + @Timeout(180) + void testRetryNoRaceCondition() throws Exception { Server server = ServerBuilder.forPort(1234).addService(new FakeService()).build().start(); ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 1234).usePlaintext().build(); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamingCallableTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamingCallableTest.java index 0d39f8704d..ec040efdf7 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamingCallableTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcDirectStreamingCallableTest.java @@ -55,22 +55,19 @@ import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -@RunWith(JUnit4.class) -public class GrpcDirectStreamingCallableTest { +class GrpcDirectStreamingCallableTest { private InProcessServer inprocessServer; private ManagedChannel channel; private FakeServiceImpl serviceImpl; private ClientContext clientContext; - @Before - public void setUp() throws InstantiationException, IllegalAccessException, IOException { + @BeforeEach + void setUp() throws InstantiationException, IllegalAccessException, IOException { String serverName = "fakeservice"; serviceImpl = new FakeServiceImpl(); inprocessServer = new InProcessServer<>(serviceImpl, serverName); @@ -89,14 +86,14 @@ public void setUp() throws InstantiationException, IllegalAccessException, IOExc .build(); } - @After - public void tearDown() { + @AfterEach + void tearDown() { channel.shutdown(); inprocessServer.stop(); } @Test - public void testBidiStreaming() throws Exception { + void testBidiStreaming() throws Exception { BidiStreamingCallable streamingCallable = GrpcCallableFactory.createBidiStreamingCallable( GrpcCallSettings.create(METHOD_STREAMING_RECOGNIZE), null, clientContext); @@ -118,7 +115,7 @@ public void testBidiStreaming() throws Exception { } @Test - public void testBidiStreamingServerError() throws Exception { + void testBidiStreamingServerError() throws Exception { BidiStreamingCallable streamingCallable = GrpcCallableFactory.createBidiStreamingCallable( GrpcCallSettings.create(METHOD_STREAMING_RECOGNIZE_ERROR), null, clientContext); @@ -141,7 +138,7 @@ public void testBidiStreamingServerError() throws Exception { } @Test - public void testBidiStreamingClientError() throws Exception { + void testBidiStreamingClientError() throws Exception { BidiStreamingCallable streamingCallable = GrpcCallableFactory.createBidiStreamingCallable( GrpcCallSettings.create(METHOD_STREAMING_RECOGNIZE_ERROR), null, clientContext); @@ -168,7 +165,7 @@ public void testBidiStreamingClientError() throws Exception { } @Test - public void testClientStreaming() throws Exception { + void testClientStreaming() throws Exception { ClientStreamingCallable streamingCallable = GrpcCallableFactory.createClientStreamingCallable( GrpcCallSettings.create(METHOD_CLIENT_STREAMING_RECOGNIZE), null, clientContext); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcHeaderInterceptorTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcHeaderInterceptorTest.java index cf49ddbcb6..0f2fcab003 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcHeaderInterceptorTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcHeaderInterceptorTest.java @@ -29,7 +29,7 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.same; import static org.mockito.Mockito.mock; @@ -45,18 +45,15 @@ import io.grpc.Metadata; import io.grpc.MethodDescriptor; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; /** Tests for {@link GrpcHeaderInterceptor}. */ -@RunWith(JUnit4.class) -public class GrpcHeaderInterceptorTest { +class GrpcHeaderInterceptorTest { @Mock private Channel channel; @@ -65,15 +62,15 @@ public class GrpcHeaderInterceptorTest { private static final MethodDescriptor method = FakeMethodDescriptor.create(); /** Sets up mocks. */ - @Before - public void setUp() { + @BeforeEach + void setUp() { MockitoAnnotations.initMocks(this); when(channel.newCall(Mockito.>any(), any(CallOptions.class))) .thenReturn(call); } @Test - public void testInterceptor() { + void testInterceptor() { Map data = ImmutableMap.of("x-goog-api-client", "abcd", "user-agent", "defg"); GrpcHeaderInterceptor interceptor = new GrpcHeaderInterceptor(data); Channel intercepted = ClientInterceptors.intercept(channel, interceptor); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningClientTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningClientTest.java index dc38795054..27af7de75c 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningClientTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningClientTest.java @@ -44,15 +44,12 @@ import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) -public class GrpcLongRunningClientTest { +class GrpcLongRunningClientTest { @Test - public void get() { + void get() { OperationsStub operationsStub = mock(OperationsStub.class); when(operationsStub.getOperationCallable()) .thenReturn( @@ -75,7 +72,7 @@ public ApiFuture futureCall( } @Test - public void cancel() { + void cancel() { OperationsStub operationsStub = mock(OperationsStub.class); when(operationsStub.cancelOperationCallable()) .thenReturn( @@ -96,7 +93,7 @@ public ApiFuture futureCall( } @Test - public void delete() { + void delete() { OperationsStub operationsStub = mock(OperationsStub.class); when(operationsStub.deleteOperationCallable()) .thenReturn( diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningTest.java index 20bceeae2c..ad45b53a21 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcLongRunningTest.java @@ -66,15 +66,12 @@ import io.grpc.Status.Code; import java.io.IOException; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class GrpcLongRunningTest { +class GrpcLongRunningTest { private static final RetrySettings FAST_RETRY_SETTINGS = RetrySettings.newBuilder() @@ -98,8 +95,8 @@ public class GrpcLongRunningTest { private FakeApiClock clock; private OperationTimedPollAlgorithm pollingAlgorithm; - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { channel = mock(ManagedChannel.class); TransportChannelProvider operationsChannelProvider = mock(TransportChannelProvider.class); TransportChannel transportChannel = @@ -154,7 +151,7 @@ public void setUp() throws IOException { } @Test - public void testCall() throws IOException { + void testCall() throws IOException { Color resp = getColor(1.0f); Money meta = getMoney("UAH"); Operation resultOperation = getOperation("testCall", resp, meta, true); @@ -176,7 +173,7 @@ public void testCall() throws IOException { } @Test - public void testFutureCallPollDoneOnFirst() throws Exception { + void testFutureCallPollDoneOnFirst() throws Exception { String opName = "testFutureCallPollDoneOnFirst"; Color resp = getColor(0.5f); Money meta = getMoney("UAH"); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcMetadataHandlerInterceptorTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcMetadataHandlerInterceptorTest.java index f8306fddfa..bfcfaad960 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcMetadataHandlerInterceptorTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcMetadataHandlerInterceptorTest.java @@ -29,8 +29,8 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -44,18 +44,15 @@ import io.grpc.Metadata; import io.grpc.MethodDescriptor; import io.grpc.Status; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; /** Tests for {@link GrpcHeaderInterceptor}. */ -@RunWith(JUnit4.class) -public class GrpcMetadataHandlerInterceptorTest { +class GrpcMetadataHandlerInterceptorTest { private static class MutableBoolean { private volatile boolean value = false; @@ -67,15 +64,15 @@ private static class MutableBoolean { private static final MethodDescriptor method = FakeMethodDescriptor.create(); /** Sets up mocks. */ - @Before - public void setUp() { + @BeforeEach + void setUp() { MockitoAnnotations.initMocks(this); when(channel.newCall(Mockito.>any(), any(CallOptions.class))) .thenReturn(call); } @Test - public void testInterceptor() { + void testInterceptor() { final MutableBoolean metadataHandlerCalled = new MutableBoolean(); final MutableBoolean trailingMetadataHandlerCalled = new MutableBoolean(); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcResponseMetadataTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcResponseMetadataTest.java index fba3f3f61e..bc294ef50e 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcResponseMetadataTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcResponseMetadataTest.java @@ -51,18 +51,14 @@ import io.grpc.Status; import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.stub.StreamObserver; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -@RunWith(JUnit4.class) -public class GrpcResponseMetadataTest { +class GrpcResponseMetadataTest { private static final String HEADER_KEY = "inprocessheaderkey"; private static final String HEADER_VALUE = "inprocessheadervalue"; @@ -75,25 +71,23 @@ public class GrpcResponseMetadataTest { private Metadata requestHeaders = null; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { String serverName = "fakeservice"; FakeServiceImplBase serviceImpl = Mockito.mock(FakeServiceImplBase.class); Mockito.doAnswer( - new Answer() { - @Override - public Void answer(InvocationOnMock invocation) { - Color color = invocation.getArgument(0); - StreamObserver observer = invocation.getArgument(1); - observer.onNext( - Money.newBuilder() - .setCurrencyCode("USD") - .setUnits((long) (color.getRed() * 255)) - .build()); - observer.onCompleted(); - return null; - } - }) + (Answer) + invocation -> { + Color color = invocation.getArgument(0); + StreamObserver observer = invocation.getArgument(1); + observer.onNext( + Money.newBuilder() + .setCurrencyCode("USD") + .setUnits((long) (color.getRed() * 255)) + .build()); + observer.onCompleted(); + return null; + }) .when(serviceImpl) .recognize(Mockito.any(), Mockito.>any()); requestHeaders = null; @@ -150,14 +144,14 @@ public void close(Status status, Metadata trailers) { .build(); } - @After - public void tearDown() { + @AfterEach + void tearDown() { channel.shutdown(); inprocessServer.stop(); } @Test - public void testResponseMetadataUnaryCall() { + void testResponseMetadataUnaryCall() { GrpcCallSettings grpcCallSettings = GrpcCallSettings.create(FakeServiceGrpc.METHOD_RECOGNIZE); @@ -167,19 +161,19 @@ public void testResponseMetadataUnaryCall() { UnaryCallable callable = GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - Assert.assertNull(requestHeaders); + Assertions.assertNull(requestHeaders); GrpcResponseMetadata responseMetadata = new GrpcResponseMetadata(); callable.call(Color.getDefaultInstance(), responseMetadata.createContextWithHandlers()); - Assert.assertNotNull(requestHeaders); + Assertions.assertNotNull(requestHeaders); Metadata metadata = responseMetadata.getMetadata(); Metadata trailingMetadata = responseMetadata.getTrailingMetadata(); - Assert.assertEquals( + Assertions.assertEquals( metadata.get(Key.of(HEADER_KEY, Metadata.ASCII_STRING_MARSHALLER)), HEADER_VALUE); - Assert.assertEquals( + Assertions.assertEquals( trailingMetadata.get(Key.of(TRAILER_KEY, Metadata.ASCII_STRING_MARSHALLER)), TRAILER_VALUE); } } diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcStatusCodeTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcStatusCodeTest.java index f078a4a927..d93b9730c4 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcStatusCodeTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcStatusCodeTest.java @@ -32,14 +32,11 @@ import com.google.api.gax.rpc.StatusCode; import com.google.common.truth.Truth; import io.grpc.Status; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) -public class GrpcStatusCodeTest { +class GrpcStatusCodeTest { @Test - public void testGrpcCodeToStatusCode() { + void testGrpcCodeToStatusCode() { testCodes(StatusCode.Code.OK, Status.Code.OK); testCodes(StatusCode.Code.CANCELLED, Status.Code.CANCELLED); testCodes(StatusCode.Code.UNKNOWN, Status.Code.UNKNOWN); diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcTransportDescriptorTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcTransportDescriptorTest.java index 456d4e73b9..51a2cd0eaf 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcTransportDescriptorTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/GrpcTransportDescriptorTest.java @@ -29,7 +29,7 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; @@ -48,17 +48,14 @@ import io.grpc.StatusException; import io.grpc.StatusRuntimeException; import java.util.Collections; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) -public class GrpcTransportDescriptorTest { +class GrpcTransportDescriptorTest { private static boolean NOT_RETRYABLE = false; private static boolean IS_RETRYABLE = true; @Test - public void translateException_StatusException_noRetry() { + void translateException_StatusException_noRetry() { Throwable originalException = new StatusException(Status.INVALID_ARGUMENT); GrpcExceptionCallable exceptionCallable = new GrpcExceptionCallable<>( @@ -73,7 +70,7 @@ public void translateException_StatusException_noRetry() { } @Test - public void translateException_StatusException_withRetry() { + void translateException_StatusException_withRetry() { Throwable originalException = new StatusException(Status.UNAVAILABLE); GrpcExceptionCallable exceptionCallable = new GrpcExceptionCallable<>( @@ -88,7 +85,7 @@ public void translateException_StatusException_withRetry() { } @Test - public void translateException_StatusRuntimeException_noRetry() { + void translateException_StatusRuntimeException_noRetry() { Throwable originalException = new StatusRuntimeException(Status.INVALID_ARGUMENT); GrpcExceptionCallable exceptionCallable = new GrpcExceptionCallable<>( @@ -103,7 +100,7 @@ public void translateException_StatusRuntimeException_noRetry() { } @Test - public void translateException_StatusRuntimeException_withRetry() { + void translateException_StatusRuntimeException_withRetry() { Throwable originalException = new StatusRuntimeException(Status.UNAVAILABLE); GrpcExceptionCallable exceptionCallable = new GrpcExceptionCallable<>( @@ -118,7 +115,7 @@ public void translateException_StatusRuntimeException_withRetry() { } @Test - public void translateException_cancelled() { + void translateException_cancelled() { GrpcExceptionCallable exceptionCallable = new GrpcExceptionCallable<>(inactiveCallable(), Collections.emptySet()); ApiFuture result = exceptionCallable.futureCall(0); @@ -129,7 +126,7 @@ public void translateException_cancelled() { } @Test - public void translateException_ApiException() { + void translateException_ApiException() { Throwable originalException = new RuntimeException("stuff went wrong"); Throwable apiException = new DataLossException( @@ -147,7 +144,7 @@ public void translateException_ApiException() { } @Test - public void translateException_RuntimeException() { + void translateException_RuntimeException() { Throwable originalException = new RuntimeException("stuff went wrong"); GrpcExceptionCallable exceptionCallable = new GrpcExceptionCallable<>( @@ -179,7 +176,7 @@ public ApiFuture futureCall(Integer request, ApiCallContext context) { }; } - public void assertInnerExceptionIsInstanceOf( + void assertInnerExceptionIsInstanceOf( Throwable thrownException, Class clazz, boolean retryable, Throwable originalException) { Truth.assertThat(thrownException).isInstanceOf(clazz); ApiException apiException = (ApiException) thrownException; diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java index a58d10ffc6..2647ac6d13 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java @@ -31,7 +31,8 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.api.core.ApiFunction; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.Builder; @@ -60,18 +61,15 @@ import java.util.logging.LogRecord; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class InstantiatingGrpcChannelProviderTest extends AbstractMtlsTransportChannelTest { +class InstantiatingGrpcChannelProviderTest extends AbstractMtlsTransportChannelTest { @Test - public void testEndpoint() { + void testEndpoint() { String endpoint = "localhost:8080"; InstantiatingGrpcChannelProvider.Builder builder = InstantiatingGrpcChannelProvider.newBuilder(); @@ -82,18 +80,22 @@ public void testEndpoint() { assertEquals(provider.getEndpoint(), endpoint); } - @Test(expected = IllegalArgumentException.class) - public void testEndpointNoPort() { - InstantiatingGrpcChannelProvider.newBuilder().setEndpoint("localhost"); + @Test + void testEndpointNoPort() { + assertThrows( + IllegalArgumentException.class, + () -> InstantiatingGrpcChannelProvider.newBuilder().setEndpoint("localhost")); } - @Test(expected = IllegalArgumentException.class) - public void testEndpointBadPort() { - InstantiatingGrpcChannelProvider.newBuilder().setEndpoint("localhost:abcd"); + @Test + void testEndpointBadPort() { + assertThrows( + IllegalArgumentException.class, + () -> InstantiatingGrpcChannelProvider.newBuilder().setEndpoint("localhost:abcd")); } @Test - public void testKeepAlive() { + void testKeepAlive() { Duration keepaliveTime = Duration.ofSeconds(1); Duration keepaliveTimeout = Duration.ofSeconds(2); boolean keepaliveWithoutCalls = true; @@ -111,14 +113,14 @@ public void testKeepAlive() { } @Test - public void testMaxInboundMetadataSize() { + void testMaxInboundMetadataSize() { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder().setMaxInboundMetadataSize(4096).build(); assertThat(provider.getMaxInboundMetadataSize()).isEqualTo(4096); } @Test - public void testCpuPoolSize() { + void testCpuPoolSize() { // happy path Builder builder = InstantiatingGrpcChannelProvider.newBuilder().setProcessorCount(2); builder.setChannelsPerCpu(2.5); @@ -135,7 +137,7 @@ public void testCpuPoolSize() { } @Test - public void testWithPoolSize() throws IOException { + void testWithPoolSize() throws IOException { ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1); executor.shutdown(); @@ -155,7 +157,7 @@ public void testWithPoolSize() throws IOException { } @Test - public void testToBuilder() { + void testToBuilder() { Duration keepaliveTime = Duration.ofSeconds(1); Duration keepaliveTimeout = Duration.ofSeconds(2); ApiFunction channelConfigurator = @@ -191,12 +193,12 @@ public void testToBuilder() { } @Test - public void testWithInterceptors() throws Exception { + void testWithInterceptors() throws Exception { testWithInterceptors(1); } @Test - public void testWithInterceptorsAndMultipleChannels() throws Exception { + void testWithInterceptorsAndMultipleChannels() throws Exception { testWithInterceptors(5); } @@ -218,7 +220,7 @@ private void testWithInterceptors(int numChannels) throws Exception { } @Test - public void testChannelConfigurator() throws IOException { + void testChannelConfigurator() throws IOException { final int numChannels = 5; // Create a mock configurator that will insert mock channels @@ -253,7 +255,7 @@ public void testChannelConfigurator() throws IOException { } @Test - public void testWithGCECredentials() throws IOException { + void testWithGCECredentials() throws IOException { ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1); executor.shutdown(); @@ -277,7 +279,7 @@ public void testWithGCECredentials() throws IOException { } @Test - public void testDirectPathXdsDisableByDefault() throws IOException { + void testDirectPathXdsDisableByDefault() throws IOException { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder().setAttemptDirectPath(true).build(); @@ -285,7 +287,7 @@ public void testDirectPathXdsDisableByDefault() throws IOException { } @Test - public void testDirectPathDisallowNullCredentials() throws IOException { + void testDirectPathDisallowNullCredentials() throws IOException { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder().build(); @@ -293,7 +295,7 @@ public void testDirectPathDisallowNullCredentials() throws IOException { } @Test - public void testDirectPathWithGDUEndpoint() { + void testDirectPathWithGDUEndpoint() { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder() .setAttemptDirectPath(true) @@ -304,7 +306,7 @@ public void testDirectPathWithGDUEndpoint() { } @Test - public void testDirectPathWithNonGDUEndpoint() { + void testDirectPathWithNonGDUEndpoint() { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder() .setAttemptDirectPath(true) @@ -315,7 +317,7 @@ public void testDirectPathWithNonGDUEndpoint() { } @Test - public void testDirectPathXdsEnabled() throws IOException { + void testDirectPathXdsEnabled() throws IOException { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder() .setAttemptDirectPath(true) @@ -327,7 +329,7 @@ public void testDirectPathXdsEnabled() throws IOException { } @Test - public void testWithNonGCECredentials() throws IOException { + void testWithNonGCECredentials() throws IOException { ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1); executor.shutdown(); @@ -355,7 +357,7 @@ public void testWithNonGCECredentials() throws IOException { } @Test - public void testWithDirectPathDisabled() throws IOException { + void testWithDirectPathDisabled() throws IOException { ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1); executor.shutdown(); @@ -383,7 +385,7 @@ public void testWithDirectPathDisabled() throws IOException { } @Test - public void testWithNoDirectPathFlagSet() throws IOException { + void testWithNoDirectPathFlagSet() throws IOException { ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1); executor.shutdown(); @@ -410,7 +412,7 @@ public void testWithNoDirectPathFlagSet() throws IOException { } @Test - public void testWithIPv6Address() throws IOException { + void testWithIPv6Address() throws IOException { ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1); executor.shutdown(); @@ -428,7 +430,7 @@ public void testWithIPv6Address() throws IOException { // Test that if ChannelPrimer is provided, it is called during creation @Test - public void testWithPrimeChannel() throws IOException { + void testWithPrimeChannel() throws IOException { // create channelProvider with different pool sizes to verify ChannelPrimer is called the // correct number of times for (int poolSize = 1; poolSize < 5; poolSize++) { @@ -452,7 +454,7 @@ public void testWithPrimeChannel() throws IOException { } @Test - public void testWithDefaultDirectPathServiceConfig() { + void testWithDefaultDirectPathServiceConfig() { InstantiatingGrpcChannelProvider provider = InstantiatingGrpcChannelProvider.newBuilder().build(); @@ -505,7 +507,7 @@ public void testWithDefaultDirectPathServiceConfig() { } @Test - public void testWithCustomDirectPathServiceConfig() { + void testWithCustomDirectPathServiceConfig() { ImmutableMap pickFirstStrategy = ImmutableMap.of("round_robin", ImmutableMap.of()); ImmutableMap childPolicy = @@ -539,7 +541,7 @@ protected Object getMtlsObjectFromTransportChannel(MtlsProvider provider) } @Test - public void testLogDirectPathMisconfigAttrempDirectPathNotSet() throws Exception { + void testLogDirectPathMisconfigAttrempDirectPathNotSet() throws Exception { FakeLogHandler logHandler = new FakeLogHandler(); InstantiatingGrpcChannelProvider.LOG.addHandler(logHandler); InstantiatingGrpcChannelProvider provider = @@ -560,7 +562,7 @@ public void testLogDirectPathMisconfigAttrempDirectPathNotSet() throws Exception } @Test - public void testLogDirectPathMisconfig_shouldNotLogInTheBuilder() { + void testLogDirectPathMisconfig_shouldNotLogInTheBuilder() { FakeLogHandler logHandler = new FakeLogHandler(); InstantiatingGrpcChannelProvider.LOG.addHandler(logHandler); InstantiatingGrpcChannelProvider.newBuilder() @@ -573,7 +575,7 @@ public void testLogDirectPathMisconfig_shouldNotLogInTheBuilder() { } @Test - public void testLogDirectPathMisconfigWrongCredential() throws Exception { + void testLogDirectPathMisconfigWrongCredential() throws Exception { FakeLogHandler logHandler = new FakeLogHandler(); InstantiatingGrpcChannelProvider.LOG.addHandler(logHandler); InstantiatingGrpcChannelProvider provider = @@ -595,7 +597,7 @@ public void testLogDirectPathMisconfigWrongCredential() throws Exception { } @Test - public void testLogDirectPathMisconfigNotOnGCE() throws Exception { + void testLogDirectPathMisconfigNotOnGCE() throws Exception { FakeLogHandler logHandler = new FakeLogHandler(); InstantiatingGrpcChannelProvider.LOG.addHandler(logHandler); InstantiatingGrpcChannelProvider provider = diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ProtoOperationTransformersTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ProtoOperationTransformersTest.java index 5ac43f1417..19122ff653 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ProtoOperationTransformersTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/ProtoOperationTransformersTest.java @@ -29,7 +29,7 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.api.gax.grpc.ProtoOperationTransformers.MetadataTransformer; import com.google.api.gax.grpc.ProtoOperationTransformers.ResponseTransformer; @@ -43,14 +43,11 @@ import com.google.type.Color; import com.google.type.Money; import io.grpc.Status.Code; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) -public class ProtoOperationTransformersTest { +class ProtoOperationTransformersTest { @Test - public void testAnyResponseTransformer() { + void testAnyResponseTransformer() { ResponseTransformer transformer = ResponseTransformer.create(Money.class); Money inputMoney = Money.newBuilder().setCurrencyCode("USD").build(); OperationSnapshot operationSnapshot = @@ -60,7 +57,7 @@ public void testAnyResponseTransformer() { } @Test - public void testAnyResponseTransformer_exception() { + void testAnyResponseTransformer_exception() { ResponseTransformer transformer = ResponseTransformer.create(Money.class); Money inputMoney = Money.newBuilder().setCurrencyCode("USD").build(); Status status = Status.newBuilder().setCode(Code.UNAVAILABLE.value()).build(); @@ -75,7 +72,7 @@ public void testAnyResponseTransformer_exception() { } @Test - public void testAnyResponseTransformer_mismatchedTypes() { + void testAnyResponseTransformer_mismatchedTypes() { ResponseTransformer transformer = ResponseTransformer.create(Money.class); Status status = Status.newBuilder().setCode(Code.OK.value()).build(); OperationSnapshot operationSnapshot = @@ -90,7 +87,7 @@ public void testAnyResponseTransformer_mismatchedTypes() { } @Test - public void testAnyMetadataTransformer() { + void testAnyMetadataTransformer() { MetadataTransformer transformer = MetadataTransformer.create(Money.class); Money inputMoney = Money.newBuilder().setCurrencyCode("USD").build(); OperationSnapshot operationSnapshot = @@ -100,7 +97,7 @@ public void testAnyMetadataTransformer() { } @Test - public void testAnyMetadataTransformer_mismatchedTypes() { + void testAnyMetadataTransformer_mismatchedTypes() { MetadataTransformer transformer = MetadataTransformer.create(Money.class); Status status = Status.newBuilder().setCode(Code.OK.value()).build(); OperationSnapshot operationSnapshot = diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/SettingsTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/SettingsTest.java index e24e36c686..6672f4c958 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/SettingsTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/SettingsTest.java @@ -29,7 +29,7 @@ */ package com.google.api.gax.grpc; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.google.api.gax.batching.BatchingSettings; import com.google.api.gax.core.CredentialsProvider; @@ -58,14 +58,11 @@ import com.google.common.collect.Lists; import com.google.common.truth.Truth; import java.io.IOException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class SettingsTest { +class SettingsTest { interface FakePagedListResponse extends PagedListResponse {} @@ -265,7 +262,7 @@ public BatchingCallSettings.Builder fakeMethodBatching() { // ==== @Test - public void customCredentials() throws IOException { + void customCredentials() throws IOException { Credentials credentials = Mockito.mock(Credentials.class); FakeStubSettings settings = @@ -287,7 +284,7 @@ public void customCredentials() throws IOException { } @Test - public void channelCustomCredentialScopes() throws IOException { + void channelCustomCredentialScopes() throws IOException { ImmutableList inputScopes = ImmutableList.builder().add("https://www.googleapis.com/auth/fakeservice").build(); @@ -319,7 +316,7 @@ public void channelCustomCredentialScopes() throws IOException { // ==== @Test - public void callSettingsToBuilder() { + void callSettingsToBuilder() { UnaryCallSettings.Builder builderA = UnaryCallSettings.newUnaryCallSettingsBuilder(); UnaryCallSettings settingsA = builderA.build(); UnaryCallSettings.Builder builderB = settingsA.toBuilder(); @@ -329,14 +326,14 @@ public void callSettingsToBuilder() { } @Test - public void unaryCallSettingsBuilderBuildDoesNotFailUnsetProperties() { + void unaryCallSettingsBuilderBuildDoesNotFailUnsetProperties() { UnaryCallSettings.Builder builder = UnaryCallSettings.newUnaryCallSettingsBuilder(); builder.build(); } @Test - public void callSettingsBuildFromTimeoutNoRetries() { + void callSettingsBuildFromTimeoutNoRetries() { Duration timeout = Duration.ofMillis(60000); UnaryCallSettings.Builder builderA = @@ -361,6 +358,6 @@ public void callSettingsBuildFromTimeoutNoRetries() { .build()); UnaryCallSettings settingsB = builderB.build(); - assertEquals("UnaryCallSettings", settingsA, settingsB); + assertEquals(settingsA, settingsB, "UnaryCallSettings"); } } diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/TimeoutTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/TimeoutTest.java index ce5f04d786..7945c23f8b 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/TimeoutTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/TimeoutTest.java @@ -55,22 +55,18 @@ import io.grpc.MethodDescriptor.MethodType; import java.io.IOException; import java.util.concurrent.TimeUnit; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.mockito.quality.Strictness; +import org.mockito.junit.jupiter.MockitoExtension; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class TimeoutTest { +@ExtendWith(MockitoExtension.class) +class TimeoutTest { private static final String CALL_OPTIONS_AUTHORITY = "RETRYING_TEST"; private static final int DEADLINE_IN_DAYS = 7; private static final int DEADLINE_IN_MINUTES = 10; @@ -83,12 +79,11 @@ public class TimeoutTest { private static final Duration initialRpcTimeout = Duration.ofSeconds(DEADLINE_IN_SECONDS); private static GrpcCallContext defaultCallContext; - @Rule public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); @Mock private Marshaller stringMarshaller; @Mock private RequestParamsExtractor paramsExtractor; @Mock private ManagedChannel managedChannel; - @BeforeClass + @BeforeAll public static void setUp() throws IOException { EndpointContext endpointContext = Mockito.mock(EndpointContext.class); Mockito.doNothing() @@ -98,7 +93,7 @@ public static void setUp() throws IOException { } @Test - public void testNonRetryUnarySettings() { + void testNonRetryUnarySettings() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -124,7 +119,7 @@ public void testNonRetryUnarySettings() { } @Test - public void testNonRetryUnarySettingsContextWithRetry() { + void testNonRetryUnarySettingsContextWithRetry() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -164,7 +159,7 @@ public void testNonRetryUnarySettingsContextWithRetry() { } @Test - public void testNonRetryUnarySettingsWithoutInitialRpcTimeout() { + void testNonRetryUnarySettingsWithoutInitialRpcTimeout() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -189,7 +184,7 @@ public void testNonRetryUnarySettingsWithoutInitialRpcTimeout() { } @Test - public void testNonRetryUnarySettingsWithoutIndividualRpcTimeout() { + void testNonRetryUnarySettingsWithoutIndividualRpcTimeout() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -213,7 +208,7 @@ public void testNonRetryUnarySettingsWithoutIndividualRpcTimeout() { } @Test - public void testNonRetryServerStreamingSettings() { + void testNonRetryServerStreamingSettings() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -239,7 +234,7 @@ public void testNonRetryServerStreamingSettings() { } @Test - public void testNonRetryServerStreamingSettingsContextWithRetry() { + void testNonRetryServerStreamingSettingsContextWithRetry() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -279,7 +274,7 @@ public void testNonRetryServerStreamingSettingsContextWithRetry() { } @Test - public void testNonRetryServerStreamingSettingsWithoutInitialRpcTimeout() { + void testNonRetryServerStreamingSettingsWithoutInitialRpcTimeout() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) @@ -304,7 +299,7 @@ public void testNonRetryServerStreamingSettingsWithoutInitialRpcTimeout() { } @Test - public void testNonRetryServerStreamingSettingsWithoutIndividualRpcTimeout() { + void testNonRetryServerStreamingSettingsWithoutIndividualRpcTimeout() { RetrySettings retrySettings = RetrySettings.newBuilder() .setTotalTimeout(totalTimeout) diff --git a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/testing/MockServiceHelperTest.java b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/testing/MockServiceHelperTest.java index 585f8ec65f..c851e93c7b 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/testing/MockServiceHelperTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/testing/MockServiceHelperTest.java @@ -29,8 +29,9 @@ */ package com.google.api.gax.grpc.testing; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -41,15 +42,12 @@ import io.grpc.ServerServiceDefinition; import java.io.IOException; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** Tests for {@link MockServiceHelper}. */ -@RunWith(JUnit4.class) public class MockServiceHelperTest { @Mock private MockGrpcService grpcService; @Mock private MockGrpcService grpcService2; @@ -57,8 +55,8 @@ public class MockServiceHelperTest { @Mock private Server server; /** Sets up mocks. */ - @Before - public void setUp() { + @BeforeEach + void setUp() { MockitoAnnotations.initMocks(this); when(grpcService.getServiceDefinition()) .thenReturn(ServerServiceDefinition.builder("fake-service").build()); @@ -67,28 +65,28 @@ public void setUp() { } @Test - public void testGetService() { + void testGetService() { MockServiceHelper serviceHelper = new MockServiceHelper(server, "fake-address", grpcService); Truth.assertThat(serviceHelper.getService()).isSameInstanceAs(grpcService); Truth.assertThat(serviceHelper.getServices().size()).isEqualTo(1); } - @Test(expected = IllegalStateException.class) - public void testGetServiceInvalid() { + @Test + void testGetServiceInvalid() { MockServiceHelper serviceHelper = new MockServiceHelper(server, "fake-address2", Arrays.asList(grpcService, grpcService2)); - serviceHelper.getService(); + assertThrows(IllegalStateException.class, serviceHelper::getService); } @Test - public void testStart() throws IOException { + void testStart() throws IOException { MockServiceHelper serviceHelper = new MockServiceHelper(server, "fake-address", grpcService); serviceHelper.start(); verify(server, times(1)).start(); } @Test - public void testReset() { + void testReset() { MockServiceHelper serviceHelper = new MockServiceHelper("fake-address", grpcService); serviceHelper.reset(); verify(grpcService, times(1)).getServiceDefinition(); @@ -96,7 +94,7 @@ public void testReset() { } @Test - public void testCreateChannelProvider() throws Exception { + void testCreateChannelProvider() throws Exception { MockServiceHelper serviceHelper = new MockServiceHelper("fake-address", grpcService); TransportChannel channel = serviceHelper.createChannelProvider().getTransportChannel(); assertNotNull(channel); diff --git a/gax-java/gax-grpc/src/test/java/com/google/longrunning/OperationsClientTest.java b/gax-java/gax-grpc/src/test/java/com/google/longrunning/OperationsClientTest.java index 0c5eaa302f..d438a8c4f4 100644 --- a/gax-java/gax-grpc/src/test/java/com/google/longrunning/OperationsClientTest.java +++ b/gax-java/gax-grpc/src/test/java/com/google/longrunning/OperationsClientTest.java @@ -29,6 +29,9 @@ */ package com.google.longrunning; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.testing.LocalChannelProvider; import com.google.api.gax.grpc.testing.MockGrpcService; @@ -44,20 +47,19 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class OperationsClientTest { +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class OperationsClientTest { private static MockOperations mockOperations; private static MockServiceHelper serviceHelper; private OperationsClient client; private LocalChannelProvider channelProvider; - @BeforeClass + @BeforeAll public static void startStaticServer() { mockOperations = new MockOperations(); serviceHelper = @@ -65,13 +67,13 @@ public static void startStaticServer() { serviceHelper.start(); } - @AfterClass + @AfterAll public static void stopServer() { serviceHelper.stop(); } - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { serviceHelper.reset(); channelProvider = serviceHelper.createChannelProvider(); OperationsSettings settings = @@ -82,14 +84,14 @@ public void setUp() throws IOException { client = OperationsClient.create(settings); } - @After - public void tearDown() { + @AfterEach + void tearDown() { client.close(); } @Test @SuppressWarnings("all") - public void getOperationTest() { + void getOperationTest() { String name2 = "name2-1052831874"; boolean done = true; Operation expectedResponse = Operation.newBuilder().setName(name2).setDone(done).build(); @@ -98,34 +100,32 @@ public void getOperationTest() { String name = "name3373707"; Operation actualResponse = client.getOperation(name); - Assert.assertEquals(expectedResponse, actualResponse); + assertEquals(expectedResponse, actualResponse); List actualRequests = mockOperations.getRequests(); - Assert.assertEquals(1, actualRequests.size()); + assertEquals(1, actualRequests.size()); GetOperationRequest actualRequest = (GetOperationRequest) actualRequests.get(0); - Assert.assertEquals(name, actualRequest.getName()); + assertEquals(name, actualRequest.getName()); } @Test @SuppressWarnings("all") - public void getOperationExceptionTest() throws Exception { + void getOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); - try { - String name = "name3373707"; - - client.getOperation(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + String name = "name3373707"; + assertThrows( + InvalidArgumentException.class, + () -> { + client.getOperation(name); + }); } @Test @SuppressWarnings("all") - public void listOperationsTest() { + void listOperationsTest() { String nextPageToken = ""; Operation operationsElement = Operation.newBuilder().build(); List operations = Arrays.asList(operationsElement); @@ -142,37 +142,35 @@ public void listOperationsTest() { ListOperationsPagedResponse pagedListResponse = client.listOperations(name, filter); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getOperationsList().get(0), resources.get(0)); + assertEquals(1, resources.size()); + assertEquals(expectedResponse.getOperationsList().get(0), resources.get(0)); List actualRequests = mockOperations.getRequests(); - Assert.assertEquals(1, actualRequests.size()); + assertEquals(1, actualRequests.size()); ListOperationsRequest actualRequest = (ListOperationsRequest) actualRequests.get(0); - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertEquals(filter, actualRequest.getFilter()); + assertEquals(name, actualRequest.getName()); + assertEquals(filter, actualRequest.getFilter()); } @Test @SuppressWarnings("all") - public void listOperationsExceptionTest() throws Exception { + void listOperationsExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); - try { - String name = "name3373707"; - String filter = "filter-1274492040"; - - client.listOperations(name, filter); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + String name = "name3373707"; + String filter = "filter-1274492040"; + assertThrows( + InvalidArgumentException.class, + () -> { + client.listOperations(name, filter); + }); } @Test @SuppressWarnings("all") - public void cancelOperationTest() { + void cancelOperationTest() { Empty expectedResponse = Empty.newBuilder().build(); mockOperations.addResponse(expectedResponse); @@ -181,31 +179,29 @@ public void cancelOperationTest() { client.cancelOperation(name); List actualRequests = mockOperations.getRequests(); - Assert.assertEquals(1, actualRequests.size()); + assertEquals(1, actualRequests.size()); CancelOperationRequest actualRequest = (CancelOperationRequest) actualRequests.get(0); - Assert.assertEquals(name, actualRequest.getName()); + assertEquals(name, actualRequest.getName()); } @Test @SuppressWarnings("all") - public void cancelOperationExceptionTest() throws Exception { + void cancelOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); - try { - String name = "name3373707"; - - client.cancelOperation(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + String name = "name3373707"; + assertThrows( + InvalidArgumentException.class, + () -> { + client.cancelOperation(name); + }); } @Test @SuppressWarnings("all") - public void deleteOperationTest() { + void deleteOperationTest() { Empty expectedResponse = Empty.newBuilder().build(); mockOperations.addResponse(expectedResponse); @@ -214,31 +210,29 @@ public void deleteOperationTest() { client.deleteOperation(name); List actualRequests = mockOperations.getRequests(); - Assert.assertEquals(1, actualRequests.size()); + assertEquals(1, actualRequests.size()); DeleteOperationRequest actualRequest = (DeleteOperationRequest) actualRequests.get(0); - Assert.assertEquals(name, actualRequest.getName()); + assertEquals(name, actualRequest.getName()); } @Test @SuppressWarnings("all") - public void deleteOperationExceptionTest() throws Exception { + void deleteOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); - try { - String name = "name3373707"; - - client.deleteOperation(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + String name = "name3373707"; + assertThrows( + InvalidArgumentException.class, + () -> { + client.deleteOperation(name); + }); } @Test @SuppressWarnings("all") - public void waitOperationTest() { + void waitOperationTest() { String name2 = "name2-1052831874"; boolean done = true; Operation expectedResponse = Operation.newBuilder().setName(name2).setDone(done).build(); @@ -250,31 +244,29 @@ public void waitOperationTest() { WaitOperationRequest.newBuilder().setName(name).setTimeout(timeout).build(); Operation actualResponse = client.waitOperation(request); - Assert.assertEquals(expectedResponse, actualResponse); + assertEquals(expectedResponse, actualResponse); List actualRequests = mockOperations.getRequests(); - Assert.assertEquals(1, actualRequests.size()); + assertEquals(1, actualRequests.size()); WaitOperationRequest actualRequest = (WaitOperationRequest) actualRequests.get(0); - Assert.assertEquals(name, actualRequest.getName()); + assertEquals(name, actualRequest.getName()); } @Test @SuppressWarnings("all") - public void waitOperationExceptionTest() throws Exception { + void waitOperationExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockOperations.addException(exception); - try { - String name = "name3373707"; - Duration timeout = Duration.newBuilder().setSeconds(5).build(); - WaitOperationRequest request = - WaitOperationRequest.newBuilder().setName(name).setTimeout(timeout).build(); - - client.waitOperation(request); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } + String name = "name3373707"; + Duration timeout = Duration.newBuilder().setSeconds(5).build(); + WaitOperationRequest request = + WaitOperationRequest.newBuilder().setName(name).setTimeout(timeout).build(); + assertThrows( + InvalidArgumentException.class, + () -> { + client.waitOperation(request); + }); } } diff --git a/gax-java/gax-httpjson/BUILD.bazel b/gax-java/gax-httpjson/BUILD.bazel index 15c81e73d4..1e134e6770 100644 --- a/gax-java/gax-httpjson/BUILD.bazel +++ b/gax-java/gax-httpjson/BUILD.bazel @@ -28,8 +28,9 @@ _COMPILE_DEPS = [ ] _TEST_COMPILE_DEPS = [ - "@junit_junit//jar", + "@org_junit_jupiter_junit_jupiter_api//jar", "@org_mockito_mockito_core//jar", + "@org_mockito_mockito_junit_jupiter//jar", "@com_google_truth_truth//jar", "//gax:gax_testlib", "@com_googlecode_java_diff_utils_diffutils//jar", diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/GaxHttpJsonPropertiesTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/GaxHttpJsonPropertiesTest.java index 487605a62a..007b100577 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/GaxHttpJsonPropertiesTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/GaxHttpJsonPropertiesTest.java @@ -30,15 +30,15 @@ package com.google.api.gax.httpjson; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GaxHttpJsonPropertiesTest { +class GaxHttpJsonPropertiesTest { private static final String X_GOOG_API_CLIENT = "x-goog-api-client"; @Test - public void testDefaultHeaderPattern() { + void testDefaultHeaderPattern() { assertTrue( GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() .matcher("gl-java/1.8_00 gapic/1.2.3-alpha gax/1.5.0 rest/1.7.0") diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpHeadersUtilsTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpHeadersUtilsTest.java index 9c305977d5..247f2b2907 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpHeadersUtilsTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpHeadersUtilsTest.java @@ -29,19 +29,19 @@ */ package com.google.api.gax.httpjson; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import com.google.api.client.http.HttpHeaders; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HttpHeadersUtilsTest { +class HttpHeadersUtilsTest { @Test - public void testSetHeader() { + void testSetHeader() { HttpHeaders headers = new HttpHeaders(); assertEquals(headers, HttpHeadersUtils.setHeader(headers, "Custom-Header", "CustomHeader")); @@ -105,7 +105,7 @@ public void testSetHeader() { } @Test - public void testSetHeaders() { + void testSetHeaders() { HttpHeaders headers = new HttpHeaders(); Map headersMap = @@ -120,7 +120,7 @@ public void testSetHeaders() { } @Test - public void testGetUserAgentValue() { + void testGetUserAgentValue() { Map headersMap = ImmutableMap.of( "Custom-Header", "CustomHeader", "User-Agent", "this is me", "accept", "Accept"); diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallContextTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallContextTest.java index fc872d3529..1da469cdb2 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallContextTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallContextTest.java @@ -29,10 +29,11 @@ */ package com.google.api.gax.httpjson; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; @@ -49,30 +50,24 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class HttpJsonCallContextTest { +class HttpJsonCallContextTest { @Test - public void testNullToSelfWrongType() { - try { - HttpJsonCallContext.createDefault().nullToSelf(FakeCallContext.createDefault()); - Assert.fail("HttpJsonCallContext should have thrown an exception"); - } catch (IllegalArgumentException expected) { - Truth.assertThat(expected) - .hasMessageThat() - .contains("context must be an instance of HttpJsonCallContext"); - } + void testNullToSelfWrongType() { + IllegalArgumentException actual = + assertThrows( + IllegalArgumentException.class, + () -> HttpJsonCallContext.createDefault().nullToSelf(FakeCallContext.createDefault())); + assertTrue(actual.getMessage().contains("context must be an instance of HttpJsonCallContext")); } @Test - public void testWithCredentials() { + void testWithCredentials() { Credentials credentials = Mockito.mock(Credentials.class); HttpJsonCallContext emptyContext = HttpJsonCallContext.createDefault(); assertNull(emptyContext.getCredentials()); @@ -81,7 +76,7 @@ public void testWithCredentials() { } @Test - public void testWithTransportChannel() { + void testWithTransportChannel() { ManagedHttpJsonChannel channel = Mockito.mock(ManagedHttpJsonChannel.class); HttpJsonCallContext context = @@ -92,22 +87,22 @@ public void testWithTransportChannel() { } @Test - public void testWithTransportChannelWrongType() { + void testWithTransportChannelWrongType() { try { FakeChannel channel = new FakeChannel(); HttpJsonCallContext.createDefault() .withTransportChannel(FakeTransportChannel.create(channel)); - Assert.fail("HttpJsonCallContext should have thrown an exception"); + Assertions.fail("HttpJsonCallContext should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected).hasMessageThat().contains("Expected HttpJsonTransportChannel"); } } @Test - public void testMergeWrongType() { + void testMergeWrongType() { try { HttpJsonCallContext.createDefault().merge(FakeCallContext.createDefault()); - Assert.fail("HttpJsonCallContext should have thrown an exception"); + Assertions.fail("HttpJsonCallContext should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected) .hasMessageThat() @@ -116,24 +111,24 @@ public void testMergeWrongType() { } @Test - public void testWithTimeout() { + void testWithTimeout() { assertNull(HttpJsonCallContext.createDefault().withTimeout(null).getTimeout()); } @Test - public void testWithNegativeTimeout() { + void testWithNegativeTimeout() { assertNull( HttpJsonCallContext.createDefault().withTimeout(Duration.ofSeconds(-1L)).getTimeout()); } @Test - public void testWithZeroTimeout() { + void testWithZeroTimeout() { assertNull( HttpJsonCallContext.createDefault().withTimeout(Duration.ofSeconds(0L)).getTimeout()); } @Test - public void testWithShorterTimeout() { + void testWithShorterTimeout() { HttpJsonCallContext ctxWithLongTimeout = HttpJsonCallContext.createDefault().withTimeout(Duration.ofSeconds(10)); @@ -147,7 +142,7 @@ public void testWithShorterTimeout() { } @Test - public void testWithLongerTimeout() { + void testWithLongerTimeout() { HttpJsonCallContext ctxWithShortTimeout = HttpJsonCallContext.createDefault().withTimeout(Duration.ofSeconds(5)); @@ -161,7 +156,7 @@ public void testWithLongerTimeout() { } @Test - public void testMergeWithNullTimeout() { + void testMergeWithNullTimeout() { Duration timeout = Duration.ofSeconds(10); HttpJsonCallContext baseContext = HttpJsonCallContext.createDefault().withTimeout(timeout); @@ -173,7 +168,7 @@ public void testMergeWithNullTimeout() { } @Test - public void testMergeWithTimeout() { + void testMergeWithTimeout() { Duration timeout = Duration.ofSeconds(19); HttpJsonCallContext ctx1 = HttpJsonCallContext.createDefault(); HttpJsonCallContext ctx2 = HttpJsonCallContext.createDefault().withTimeout(timeout); @@ -182,7 +177,7 @@ public void testMergeWithTimeout() { } @Test - public void testMergeWithTracer() { + void testMergeWithTracer() { ApiTracer explicitTracer = Mockito.mock(ApiTracer.class); HttpJsonCallContext ctxWithExplicitTracer = HttpJsonCallContext.createDefault().withTracer(explicitTracer); @@ -204,7 +199,7 @@ public void testMergeWithTracer() { } @Test - public void testWithRetrySettings() { + void testWithRetrySettings() { RetrySettings retrySettings = Mockito.mock(RetrySettings.class); HttpJsonCallContext emptyContext = HttpJsonCallContext.createDefault(); assertNull(emptyContext.getRetrySettings()); @@ -213,7 +208,7 @@ public void testWithRetrySettings() { } @Test - public void testWithRetryableCodes() { + void testWithRetryableCodes() { Set codes = Collections.singleton(StatusCode.Code.UNAVAILABLE); HttpJsonCallContext emptyContext = HttpJsonCallContext.createDefault(); assertNull(emptyContext.getRetryableCodes()); @@ -222,7 +217,7 @@ public void testWithRetryableCodes() { } @Test - public void testWithExtraHeaders() { + void testWithExtraHeaders() { Map> headers = ImmutableMap.of("k", Arrays.asList("v")); ApiCallContext emptyContext = HttpJsonCallContext.createDefault(); assertTrue(emptyContext.getExtraHeaders().isEmpty()); @@ -231,7 +226,7 @@ public void testWithExtraHeaders() { } @Test - public void testWithOptions() { + void testWithOptions() { ApiCallContext emptyCallContext = HttpJsonCallContext.createDefault(); ApiCallContext.Key contextKey1 = ApiCallContext.Key.create("testKey1"); ApiCallContext.Key contextKey2 = ApiCallContext.Key.create("testKey2"); @@ -249,7 +244,7 @@ public void testWithOptions() { } @Test - public void testMergeOptions() { + void testMergeOptions() { ApiCallContext emptyCallContext = HttpJsonCallContext.createDefault(); ApiCallContext.Key contextKey1 = ApiCallContext.Key.create("testKey1"); ApiCallContext.Key contextKey2 = ApiCallContext.Key.create("testKey2"); diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallableFactoryTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallableFactoryTest.java index 4d0785f242..7f317a60bf 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallableFactoryTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonCallableFactoryTest.java @@ -39,15 +39,12 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -@RunWith(JUnit4.class) -public class HttpJsonCallableFactoryTest { +class HttpJsonCallableFactoryTest { @Test - public void testGetSpanName() { + void testGetSpanName() { Map validNames = ImmutableMap.of( "compute.projects.disableXpnHost", SpanName.of("compute.projects", "disableXpnHost"), @@ -69,7 +66,7 @@ public void testGetSpanName() { } @Test - public void testGetSpanNameInvalid() { + void testGetSpanNameInvalid() { List invalidNames = ImmutableList.of("no_split", ".no_client"); for (String invalidName : invalidNames) { diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallImplTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallImplTest.java index 0355dd0d4b..e65c9d9758 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallImplTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallImplTest.java @@ -39,14 +39,14 @@ import java.util.concurrent.Executor; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) -public class HttpJsonClientCallImplTest { +@ExtendWith(MockitoExtension.class) +class HttpJsonClientCallImplTest { @Mock private ApiMethodDescriptor apiMethodDescriptor; @Mock private HttpResponseParser httpResponseParser; @Mock private HttpJsonCallOptions httpJsonCallOptions; @@ -56,7 +56,7 @@ public class HttpJsonClientCallImplTest { @Mock private HttpJsonClientCall.Listener listener; @Test - public void responseReceived_noCancellationTask() { + void responseReceived_noCancellationTask() { ScheduledThreadPoolExecutor deadlineSchedulerExecutor = new ScheduledThreadPoolExecutor(1); // Null timeout means no timeout task created Mockito.when(httpJsonCallOptions.getTimeout()).thenReturn(null); @@ -86,8 +86,7 @@ public void responseReceived_noCancellationTask() { } @Test - public void responseReceived_cancellationTaskExists_isCancelledProperly() - throws InterruptedException { + void responseReceived_cancellationTaskExists_isCancelledProperly() throws InterruptedException { ScheduledThreadPoolExecutor deadlineSchedulerExecutor = new ScheduledThreadPoolExecutor(1); // SetRemoveOnCancelPolicy will immediately remove the task from the work queue // when the task is cancelled diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallsTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallsTest.java index c4cdcf1390..7e2d9cb946 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallsTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientCallsTest.java @@ -30,7 +30,7 @@ package com.google.api.gax.httpjson; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.api.gax.rpc.EndpointContext; import com.google.api.gax.rpc.StatusCode; @@ -38,14 +38,11 @@ import com.google.auth.Credentials; import com.google.auth.Retryable; import java.io.IOException; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -@RunWith(JUnit4.class) -public class HttpJsonClientCallsTest { +class HttpJsonClientCallsTest { // Auth Library's GoogleAuthException is package-private. Copy basic functionality for tests private static class GoogleAuthException extends IOException implements Retryable { @@ -74,8 +71,8 @@ public int getRetryCount() { private HttpJsonCallOptions callOptions; private HttpJsonCallContext callContext; - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { credentials = Mockito.mock(Credentials.class); endpointContext = Mockito.mock(EndpointContext.class); mockChannel = Mockito.mock(HttpJsonChannel.class); @@ -95,14 +92,14 @@ public void setUp() throws IOException { } @Test - public void testValidUniverseDomain() { + void testValidUniverseDomain() { HttpJsonClientCalls.newCall(descriptor, callContext); Mockito.verify(mockChannel, Mockito.times(1)).newCall(descriptor, callOptions); } // This test is when the universe domain does not match @Test - public void testInvalidUniverseDomain() throws IOException { + void testInvalidUniverseDomain() throws IOException { Mockito.doThrow( new UnauthenticatedException( null, HttpJsonStatusCode.of(StatusCode.Code.UNAUTHENTICATED), false)) @@ -121,7 +118,7 @@ public void testInvalidUniverseDomain() throws IOException { // This test is when the MDS is unable to return a valid universe domain @Test - public void testUniverseDomainNotReady_shouldRetry() throws IOException { + void testUniverseDomainNotReady_shouldRetry() throws IOException { Mockito.doThrow(new GoogleAuthException(true)) .when(endpointContext) .validateUniverseDomain( diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientInterceptorTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientInterceptorTest.java index 463b76112b..dc5844616d 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientInterceptorTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonClientInterceptorTest.java @@ -46,18 +46,15 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class HttpJsonClientInterceptorTest { +class HttpJsonClientInterceptorTest { private static class CapturingClientInterceptor implements HttpJsonClientInterceptor { // Manually capturing arguments instead of using Mockito. This is intentional, as this @@ -143,7 +140,7 @@ public void onClose(int statusCode, HttpJsonMetadata trailers) { private CapturingClientInterceptor interceptor; private ManagedHttpJsonChannel channel; - @BeforeClass + @BeforeAll public static void initialize() { executorService = Executors.newFixedThreadPool( @@ -155,13 +152,13 @@ public static void initialize() { }); } - @AfterClass + @AfterAll public static void destroy() { executorService.shutdownNow(); } - @Before - public void setUp() throws IOException { + @BeforeEach + void setUp() throws IOException { interceptor = new CapturingClientInterceptor(); channel = InstantiatingHttpJsonChannelProvider.newBuilder() @@ -175,13 +172,13 @@ public void setUp() throws IOException { .getManagedChannel(); } - @After - public void tearDown() { + @AfterEach + void tearDown() { MOCK_SERVICE.reset(); } @Test - public void testCustomInterceptor() throws ExecutionException, InterruptedException, IOException { + void testCustomInterceptor() throws ExecutionException, InterruptedException, IOException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectCallableTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectCallableTest.java index 619052744a..0c14779bc8 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectCallableTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectCallableTest.java @@ -49,18 +49,15 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class HttpJsonDirectCallableTest { +class HttpJsonDirectCallableTest { private static final ApiMethodDescriptor FAKE_METHOD_DESCRIPTOR = ApiMethodDescriptor.newBuilder() @@ -111,7 +108,7 @@ public class HttpJsonDirectCallableTest { private static HttpJsonCallContext defaultCallContext; - @BeforeClass + @BeforeAll public static void initialize() throws IOException { executorService = Executors.newFixedThreadPool( @@ -133,18 +130,18 @@ public static void initialize() throws IOException { .withEndpointContext(endpointContext); } - @AfterClass + @AfterAll public static void destroy() { executorService.shutdownNow(); } - @After - public void tearDown() { + @AfterEach + void tearDown() { MOCK_SERVICE.reset(); } @Test - public void testSuccessfulUnaryResponse() throws ExecutionException, InterruptedException { + void testSuccessfulUnaryResponse() throws ExecutionException, InterruptedException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -173,7 +170,7 @@ public void testSuccessfulUnaryResponse() throws ExecutionException, Interrupted * @throws ExecutionException */ @Test - public void testSuccessfulMultipleResponsesForUnaryCall() + void testSuccessfulMultipleResponsesForUnaryCall() throws InterruptedException, ExecutionException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -203,8 +200,7 @@ public void testSuccessfulMultipleResponsesForUnaryCall() * @throws ExecutionException */ @Test - public void testErrorMultipleResponsesForUnaryCall() - throws InterruptedException, ExecutionException { + void testErrorMultipleResponsesForUnaryCall() throws InterruptedException, ExecutionException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -231,7 +227,7 @@ public void testErrorMultipleResponsesForUnaryCall() * @throws InterruptedException */ @Test - public void testErrorUnaryResponse() throws InterruptedException { + void testErrorUnaryResponse() throws InterruptedException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -242,7 +238,7 @@ public void testErrorUnaryResponse() throws InterruptedException { try { callable.futureCall(createTestMessage(2), defaultCallContext).get(); - Assert.fail("No exception raised"); + Assertions.fail("No exception raised"); } catch (ExecutionException e) { HttpResponseException respExp = (HttpResponseException) e.getCause(); assertThat(respExp.getStatusCode()).isEqualTo(400); @@ -258,7 +254,7 @@ public void testErrorUnaryResponse() throws InterruptedException { * @throws InterruptedException */ @Test - public void testErrorNullContentSuccessfulResponse() throws InterruptedException { + void testErrorNullContentSuccessfulResponse() throws InterruptedException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -266,7 +262,7 @@ public void testErrorNullContentSuccessfulResponse() throws InterruptedException try { callable.futureCall(createTestMessage(2), defaultCallContext).get(); - Assert.fail("No exception raised"); + Assertions.fail("No exception raised"); } catch (ExecutionException e) { HttpJsonStatusRuntimeException respExp = (HttpJsonStatusRuntimeException) e.getCause(); assertThat(respExp.getStatusCode()).isEqualTo(200); @@ -282,7 +278,7 @@ public void testErrorNullContentSuccessfulResponse() throws InterruptedException * @throws InterruptedException */ @Test - public void testErrorNullContentFailedResponse() throws InterruptedException { + void testErrorNullContentFailedResponse() throws InterruptedException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -290,7 +286,7 @@ public void testErrorNullContentFailedResponse() throws InterruptedException { try { callable.futureCall(createTestMessage(2), defaultCallContext).get(); - Assert.fail("No exception raised"); + Assertions.fail("No exception raised"); } catch (ExecutionException e) { HttpResponseException respExp = (HttpResponseException) e.getCause(); assertThat(respExp.getStatusCode()).isEqualTo(400); @@ -304,7 +300,7 @@ public void testErrorNullContentFailedResponse() throws InterruptedException { * @throws InterruptedException */ @Test - public void testErrorNon2xxOr4xxResponse() throws InterruptedException { + void testErrorNon2xxOr4xxResponse() throws InterruptedException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -315,7 +311,7 @@ public void testErrorNon2xxOr4xxResponse() throws InterruptedException { try { callable.futureCall(createTestMessage(2), defaultCallContext).get(); - Assert.fail("No exception raised"); + Assertions.fail("No exception raised"); } catch (ExecutionException e) { HttpResponseException respExp = (HttpResponseException) e.getCause(); assertThat(respExp.getStatusCode()).isEqualTo(500); @@ -331,7 +327,7 @@ public void testErrorNon2xxOr4xxResponse() throws InterruptedException { * @throws InterruptedException */ @Test - public void testDeadlineExceededResponse() throws InterruptedException { + void testDeadlineExceededResponse() throws InterruptedException { HttpJsonDirectCallable callable = new HttpJsonDirectCallable<>(FAKE_METHOD_DESCRIPTOR); @@ -342,7 +338,7 @@ public void testDeadlineExceededResponse() throws InterruptedException { try { callable.futureCall(createTestMessage(10), callContext).get(); - Assert.fail("No exception raised"); + Assertions.fail("No exception raised"); } catch (ExecutionException e) { HttpJsonStatusRuntimeException respExp = (HttpJsonStatusRuntimeException) e.getCause(); assertThat(respExp.getStatusCode()).isEqualTo(504); diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java index 3fc1724439..5cae0fda31 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonDirectServerStreamingCallableTest.java @@ -61,17 +61,14 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.threeten.bp.Duration; -@RunWith(JUnit4.class) -public class HttpJsonDirectServerStreamingCallableTest { +class HttpJsonDirectServerStreamingCallableTest { private static final Color DEFAULT_REQUEST = Color.newBuilder().setRed(0.5f).build(); private static final Color ASYNC_REQUEST = DEFAULT_REQUEST.toBuilder().setGreen(1000).build(); private static final Color ERROR_REQUEST = Color.newBuilder().setRed(-1).build(); @@ -89,12 +86,12 @@ public class HttpJsonDirectServerStreamingCallableTest { private MockHttpService mockService; ApiMethodDescriptor methodServerStreamingRecognize; - @Before - public void initialize() throws IOException { + @BeforeEach + void initialize() throws IOException { initialize(Duration.ofSeconds(30)); } - public void initialize(Duration timeout) throws IOException { + void initialize(Duration timeout) throws IOException { this.methodServerStreamingRecognize = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.v1.Fake/ServerStreamingRecognize") @@ -162,14 +159,14 @@ public void initialize(Duration timeout) throws IOException { clientContext); } - @After - public void destroy() throws InterruptedException { + @AfterEach + void destroy() throws InterruptedException { executorService.shutdown(); channel.shutdown(); } @Test - public void testBadContext() { + void testBadContext() { mockService.addResponse(new Money[] {DEFAULT_RESPONSE}); // Create a local callable with a bad context ServerStreamingCallable streamingCallable = @@ -186,7 +183,7 @@ public void testBadContext() { MoneyObserver observer = new MoneyObserver(true, latch); try { streamingCallable.call(DEFAULT_REQUEST, observer); - Assert.fail("Callable should have thrown an exception"); + Assertions.fail("Callable should have thrown an exception"); } catch (IllegalArgumentException expected) { Truth.assertThat(expected) .hasMessageThat() @@ -195,7 +192,7 @@ public void testBadContext() { } @Test - public void testServerStreamingStart() throws InterruptedException { + void testServerStreamingStart() throws InterruptedException { mockService.addResponse(new Money[] {DEFAULT_RESPONSE}); CountDownLatch latch = new CountDownLatch(1); MoneyObserver moneyObserver = new MoneyObserver(true, latch); @@ -206,7 +203,7 @@ public void testServerStreamingStart() throws InterruptedException { } @Test - public void testServerStreaming() throws InterruptedException { + void testServerStreaming() throws InterruptedException { mockService.addResponse(new Money[] {DEFAULT_RESPONSE, DEFAULTER_RESPONSE}); CountDownLatch latch = new CountDownLatch(3); MoneyObserver moneyObserver = new MoneyObserver(true, latch); @@ -220,7 +217,7 @@ public void testServerStreaming() throws InterruptedException { } @Test - public void testManualFlowControl() throws Exception { + void testManualFlowControl() throws Exception { mockService.addResponse(new Money[] {DEFAULT_RESPONSE}); CountDownLatch latch = new CountDownLatch(2); MoneyObserver moneyObserver = new MoneyObserver(false, latch); @@ -240,7 +237,7 @@ public void testManualFlowControl() throws Exception { } @Test - public void testCancelClientCall() throws Exception { + void testCancelClientCall() throws Exception { mockService.addResponse(new Money[] {DEFAULT_RESPONSE}); CountDownLatch latch = new CountDownLatch(1); MoneyObserver moneyObserver = new MoneyObserver(false, latch); @@ -256,7 +253,7 @@ public void testCancelClientCall() throws Exception { } @Test - public void testOnResponseError() throws Throwable { + void testOnResponseError() throws Throwable { mockService.addException(404, new RuntimeException("some error")); CountDownLatch latch = new CountDownLatch(1); @@ -281,7 +278,7 @@ public void testOnResponseError() throws Throwable { } @Test - public void testObserverErrorCancelsCall() throws Throwable { + void testObserverErrorCancelsCall() throws Throwable { mockService.addResponse(new Money[] {DEFAULT_RESPONSE}); final RuntimeException expectedCause = new RuntimeException("some error"); final SettableApiFuture actualErrorF = SettableApiFuture.create(); @@ -321,7 +318,7 @@ protected void onCompleteImpl() { } @Test - public void testBlockingServerStreaming() { + void testBlockingServerStreaming() { mockService.addResponse(new Money[] {DEFAULT_RESPONSE}); Color request = Color.newBuilder().setRed(0.5f).build(); ServerStream response = streamingCallable.call(request); @@ -333,7 +330,7 @@ public void testBlockingServerStreaming() { // This test ensures that the server-side streaming does not exceed the timeout value @Test - public void testDeadlineExceededServerStreaming() throws InterruptedException, IOException { + void testDeadlineExceededServerStreaming() throws InterruptedException, IOException { // set a low timeout to trigger deadline-exceeded sooner initialize(Duration.ofSeconds(1)); diff --git a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonLongRunningClientTest.java b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonLongRunningClientTest.java index 702f327a6b..0858ae350c 100644 --- a/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonLongRunningClientTest.java +++ b/gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpJsonLongRunningClientTest.java @@ -30,7 +30,7 @@ package com.google.api.gax.httpjson; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -42,17 +42,17 @@ import com.google.common.truth.Truth; import com.google.protobuf.Field; import com.google.protobuf.Option; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class HttpJsonLongRunningClientTest { +class HttpJsonLongRunningClientTest { private OperationSnapshotFactory operationSnapFact; private PollingRequestFactory