diff --git a/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy b/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy index 5647063..c565eef 100644 --- a/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy +++ b/src/test/groovy/io/codearte/gradle/nexus/functional/MockedFunctionalSpec.groovy @@ -32,7 +32,7 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet def "should not do request for staging profile when provided in configuration on #testedTaskName task"() { given: stubGetOneRepositoryWithProfileIdAndContent(stagingProfileId, - createResponseMapWithGivenRepos([aRepoInStateAndId(repoTypeToReturn, REPO_ID_1)])) + createResponseMapWithGivenRepos([aRepoInStateAndIdFull(REPO_ID_1, repoTypeToReturn)])) and: stubGetRepositoryStateByIdForConsecutiveStates(REPO_ID_1, repositoryStatesToGetById) and: @@ -56,9 +56,9 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet and: verify(0, getRequestedFor(urlEqualTo("/staging/profiles"))) where: - testedTaskName | repoTypeToReturn | repositoryStatesToGetById - "closeRepository" | "open" | [RepositoryState.CLOSED] - "promoteRepository" | "closed" | [RepositoryState.RELEASED] + testedTaskName | repoTypeToReturn | repositoryStatesToGetById + "closeRepository" | RepositoryState.OPEN | [RepositoryState.CLOSED] + "promoteRepository" | RepositoryState.CLOSED | [RepositoryState.RELEASED] } def "should send request for staging profile when not provided in configuration on #testedTaskName task"() { @@ -66,7 +66,7 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet stubGetStagingProfilesWithJson(this.getClass().getResource("/io/codearte/gradle/nexus/logic/2stagingProfilesShrunkResponse.json").text) and: stubGetOneRepositoryWithProfileIdAndContent(stagingProfileId, - createResponseMapWithGivenRepos([aRepoInStateAndId(repoTypeToReturn, REPO_ID_1)])) + createResponseMapWithGivenRepos([aRepoInStateAndIdFull(REPO_ID_1, repoTypeToReturn)])) and: stubGetRepositoryStateByIdForConsecutiveStates(REPO_ID_1, repositoryStatesToGetById) and: @@ -90,9 +90,9 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet and: verify(1, getRequestedFor(urlEqualTo("/staging/profiles"))) where: - testedTaskName | repoTypeToReturn | repositoryStatesToGetById - "closeRepository" | "open" | [RepositoryState.CLOSED] - "promoteRepository" | "closed" | [RepositoryState.RELEASED] + testedTaskName | repoTypeToReturn | repositoryStatesToGetById + "closeRepository" | RepositoryState.OPEN | [RepositoryState.CLOSED] + "promoteRepository" | RepositoryState.CLOSED | [RepositoryState.RELEASED] } def "should reuse stagingProfileId AND stagingRepositoryId from closeRepository in promoteRepository when called together"() { @@ -235,7 +235,7 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet def "should wait on #operationName operation until transitioning is finished"() { given: stubGetOneRepositoryWithProfileIdAndContent(stagingProfileId, - createResponseMapWithGivenRepos([aRepoInStateAndId(repoStates[0].name(), REPO_ID_1)])) + createResponseMapWithGivenRepos([aRepoInStateAndIdFull(REPO_ID_1, repoStates[0])])) and: stubGetRepositoryStateByIdForConsecutiveStates(REPO_ID_1, repoStates, [true, false]) and: @@ -332,14 +332,14 @@ class MockedFunctionalSpec extends BaseNexusStagingFunctionalSpec implements Fet private void stubGetOneOpenRepositoryAndOneClosedInFirstCallAndTwoClosedInTheNext(String stagingProfileId) { stubGetGivenRepositoriesInFirstAndSecondCall(stagingProfileId, - [aRepoInStateAndId("open", REPO_ID_1), aRepoInStateAndId("closed", REPO_ID_2)], - [aRepoInStateAndId("closed", REPO_ID_1), aRepoInStateAndId("closed", REPO_ID_2)]) + [aRepoInStateAndIdFull(REPO_ID_1, RepositoryState.OPEN), aRepoInStateAndIdFull(REPO_ID_2, RepositoryState.CLOSED)], + [aRepoInStateAndIdFull(REPO_ID_1, RepositoryState.CLOSED), aRepoInStateAndIdFull(REPO_ID_2, RepositoryState.CLOSED)]) } private void stubGetOneOpenRepositoryInFirstCallAndOneClosedInTheNext(String stagingProfileId) { stubGetGivenRepositoriesInFirstAndSecondCall(stagingProfileId, - [aRepoInStateAndId("open", REPO_ID_1)], - [aRepoInStateAndId("closed", REPO_ID_1)]) + [aRepoInStateAndIdFull(REPO_ID_1, RepositoryState.OPEN)], + [aRepoInStateAndIdFull(REPO_ID_1, RepositoryState.CLOSED)]) } private void stubGetGivenRepositoriesInFirstAndSecondCall(String stagingProfileId, List repositoriesToReturnInFirstCall, diff --git a/src/test/groovy/io/codearte/gradle/nexus/logic/FetcherResponseTrait.groovy b/src/test/groovy/io/codearte/gradle/nexus/logic/FetcherResponseTrait.groovy index 106859e..234b62b 100644 --- a/src/test/groovy/io/codearte/gradle/nexus/logic/FetcherResponseTrait.groovy +++ b/src/test/groovy/io/codearte/gradle/nexus/logic/FetcherResponseTrait.groovy @@ -6,12 +6,6 @@ trait FetcherResponseTrait { return [data: repositories] } - @Deprecated - Map aRepoInStateAndId(String type, String id) { - return aRepoInStateAndIdFull(id, RepositoryState.parseString(type)) - } - - @SuppressWarnings("GrDeprecatedAPIUsage") Map aRepoInStateAndIdFull(String id, RepositoryState state, boolean isTransitioning = false) { return aRepoInStateAndIdFull(id, state.toString(), isTransitioning) diff --git a/src/test/groovy/io/codearte/gradle/nexus/logic/RepositoryFetcherSpec.groovy b/src/test/groovy/io/codearte/gradle/nexus/logic/RepositoryFetcherSpec.groovy index ab37586..f035343 100644 --- a/src/test/groovy/io/codearte/gradle/nexus/logic/RepositoryFetcherSpec.groovy +++ b/src/test/groovy/io/codearte/gradle/nexus/logic/RepositoryFetcherSpec.groovy @@ -51,18 +51,18 @@ class RepositoryFetcherSpec extends BaseOperationExecutorSpec implements Fetcher def "should fail with meaningful exception on too many repositories in given state #state"() { given: client.get(GET_REPOSITORY_ID_FULL_URL) >> { - createResponseMapWithGivenRepos([aRepoInStateAndId(state, TEST_REPOSITORY_ID), - aRepoInStateAndId(state, TEST_REPOSITORY_ID + "2")]) + createResponseMapWithGivenRepos([aRepoInStateAndIdFull(TEST_REPOSITORY_ID, state), + aRepoInStateAndIdFull(TEST_REPOSITORY_ID + "2", state)]) } when: - fetcher."get${state.capitalize()}RepositoryIdForStagingProfileId"(TEST_STAGING_PROFILE_ID) + fetcher."get${state.name().toLowerCase().capitalize()}RepositoryIdForStagingProfileId"(TEST_STAGING_PROFILE_ID) then: def e = thrown(WrongNumberOfRepositories) e.message == "Wrong number of received repositories in state '$state'. Expected 1, received 2".toString() e.numberOfRepositories == 2 - e.state == state + e.state == state.toString() where: - state << ["open", "closed"] + state << [RepositoryState.OPEN, RepositoryState.CLOSED] } def "should fail with meaningful exception on wrong repo state returned from server"() { @@ -80,14 +80,14 @@ class RepositoryFetcherSpec extends BaseOperationExecutorSpec implements Fetcher } private Map anOpenRepo() { - return aRepoInStateAndId("open", TEST_REPOSITORY_ID) + return aRepoInStateAndIdFull(TEST_REPOSITORY_ID, RepositoryState.OPEN) } private Map aClosedRepo() { - return aRepoInStateAndId("closed", TEST_REPOSITORY_ID) + return aRepoInStateAndIdFull(TEST_REPOSITORY_ID, RepositoryState.CLOSED) } - private Map aRepoInState(String type) { - return aRepoInStateAndId(type, TEST_REPOSITORY_ID) + private Map aRepoInState(String state) { + return aRepoInStateAndIdFull(TEST_REPOSITORY_ID, RepositoryState.parseString(state)) } }