ExternalIdIT: Migrate from try-catch-fail to assertThrows
Change-Id: Iac1eb92799e5007b4b09c72bced3eb597989534b
This commit is contained in:
@@ -258,24 +258,22 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fetchExternalIdsBranch() throws Exception {
|
public void fetchExternalIdsBranch() throws Exception {
|
||||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers, user);
|
final TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers, user);
|
||||||
|
|
||||||
// refs/meta/external-ids is only visible to users with the 'Access Database' capability
|
// refs/meta/external-ids is only visible to users with the 'Access Database' capability
|
||||||
try {
|
TransportException thrown =
|
||||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
|
assertThrows(
|
||||||
fail("expected TransportException");
|
TransportException.class, () -> fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS));
|
||||||
} catch (TransportException e) {
|
assertThat(thrown)
|
||||||
assertThat(e.getMessage())
|
.hasMessageThat()
|
||||||
.isEqualTo(
|
.isEqualTo("Remote does not have " + RefNames.REFS_EXTERNAL_IDS + " available for fetch.");
|
||||||
"Remote does not have " + RefNames.REFS_EXTERNAL_IDS + " available for fetch.");
|
|
||||||
}
|
|
||||||
|
|
||||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||||
|
|
||||||
// re-clone to get new request context, otherwise the old global capabilities are still cached
|
// re-clone to get new request context, otherwise the old global capabilities are still cached
|
||||||
// in the IdentifiedUser object
|
// in the IdentifiedUser object
|
||||||
allUsersRepo = cloneProject(allUsers, user);
|
TestRepository<InMemoryRepository> allUsersRepo2 = cloneProject(allUsers, user);
|
||||||
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
|
fetch(allUsersRepo2, RefNames.REFS_EXTERNAL_IDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user