Use correct namespace of created repository

This commit is contained in:
René Pfeuffer
2018-07-05 12:19:31 +02:00
parent 4bdcb0cae8
commit bbce9b7ca2
11 changed files with 37 additions and 29 deletions

View File

@@ -62,7 +62,7 @@ public class GroupRootResourceTest {
@Before
public void prepareEnvironment() throws IOException, GroupException {
initMocks(this);
doNothing().when(groupManager).create(groupCaptor.capture());
when(groupManager.create(groupCaptor.capture())).thenAnswer(invocation -> invocation.getArguments()[0]);
doNothing().when(groupManager).modify(groupCaptor.capture());
Group group = createDummyGroup();

View File

@@ -158,7 +158,13 @@ public class RepositoryRootResourceTest {
}
@Test
public void shouldCreateNewRepository() throws URISyntaxException, IOException, RepositoryException {
public void shouldCreateNewRepositoryInCorrectNamespace() throws URISyntaxException, IOException, RepositoryException {
when(repositoryManager.create(any())).thenAnswer(invocation -> {
Repository repository = (Repository) invocation.getArguments()[0];
repository.setNamespace("otherspace");
return repository;
});
URL url = Resources.getResource("sonia/scm/api/v2/repository-test-update.json");
byte[] repositoryJson = Resources.toByteArray(url);
@@ -171,7 +177,7 @@ public class RepositoryRootResourceTest {
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_CREATED, response.getStatus());
assertEquals("/v2/repositories/space/repo", response.getOutputHeaders().get("Location").get(0).toString());
assertEquals("/v2/repositories/otherspace/repo", response.getOutputHeaders().get("Location").get(0).toString());
verify(repositoryManager).create(any(Repository.class));
}

View File

@@ -67,7 +67,7 @@ public class UserRootResourceTest {
public void prepareEnvironment() throws IOException, UserException {
initMocks(this);
User dummyUser = createDummyUser("Neo");
doNothing().when(userManager).create(userCaptor.capture());
when(userManager.create(userCaptor.capture())).thenAnswer(invocation -> invocation.getArguments()[0]);
doNothing().when(userManager).modify(userCaptor.capture());
doNothing().when(userManager).delete(userCaptor.capture());