Skip to content

Commit

Permalink
[#21] Remove deprecated test method
Browse files Browse the repository at this point in the history
  • Loading branch information
szpak committed Mar 26, 2017
1 parent a851d6e commit 3fa8762
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -56,17 +56,17 @@ 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"() {
given:
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:
Expand All @@ -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"() {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<Map> repositoriesToReturnInFirstCall,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"() {
Expand All @@ -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))
}
}

0 comments on commit 3fa8762

Please sign in to comment.