ppapou commented on a change in pull request #879: URL: https://github.com/apache/incubator-dlab/pull/879#discussion_r480552067
########## File path: services/self-service/src/test/java/com/epam/dlab/backendapi/resources/ProjectResourceTest.java ########## @@ -50,81 +58,126 @@ public class ProjectResourceTest extends TestBase { - private ProjectService projectService = mock(ProjectService.class); - private AccessKeyService keyService = mock(AccessKeyService.class); - - @Rule - public final ResourceTestRule resources = getResourceTestRuleInstance( - new ProjectResource(projectService, keyService)); - - @Before - public void setup() throws AuthenticationException { - authSetup(); - } - - @Test - public void stopProject() { - final Response response = resources.getJerseyTest() - .target("project/stop") - .request() - .header("Authorization", "Bearer " + TOKEN) - .post(Entity.json(getProjectActionDTO())); - - assertEquals(HttpStatus.SC_ACCEPTED, response.getStatus()); - verify(projectService).stopWithResources(any(UserInfo.class), anyList(), anyString()); - verifyNoMoreInteractions(projectService); - } - - @Test - public void startProject() { - final Response response = resources.getJerseyTest() - .target("project/start") - .request() - .header("Authorization", "Bearer " + TOKEN) - .post(Entity.json(getProjectActionDTO())); - - assertEquals(HttpStatus.SC_ACCEPTED, response.getStatus()); - verify(projectService).start(any(UserInfo.class), anyList(), anyString()); - verifyNoMoreInteractions(projectService); - } - - @Test - public void generate() { - when(keyService.generateKeys(any(UserInfo.class))).thenReturn(new KeysDTO("somePublicKey", "somePrivateKey", - "user")); - - final Response response = resources.getJerseyTest() - .target("/project/keys") - .request() - .header("Authorization", "Bearer " + TOKEN) - .post(Entity.json("")); - - assertEquals(HttpStatus.SC_OK, response.getStatus()); - assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); - - verify(keyService).generateKeys(getUserInfo()); - verifyNoMoreInteractions(keyService); - } - - @Test - public void generateKeysWithException() { - doThrow(new DlabException("Can not generate private/public key pair due to")) - .when(keyService).generateKeys(any(UserInfo.class)); - - final Response response = resources.getJerseyTest() - .target("/project/keys") - .request() - .header("Authorization", "Bearer " + TOKEN) - .post(Entity.json("")); - - assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); - assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); - - verify(keyService).generateKeys(getUserInfo()); - verifyNoMoreInteractions(keyService); - } - - private ProjectActionFormDTO getProjectActionDTO() { - return new ProjectActionFormDTO("DLAB", Collections.singletonList("https://localhost:8083/")); - } + private ProjectService projectService = mock(ProjectService.class); + private AccessKeyService keyService = mock(AccessKeyService.class); + private String PROJECT_NAME = "DLAB"; Review comment: @Mock annotation will cause a Null pointer exception ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@dlab.apache.org For additional commands, e-mail: dev-h...@dlab.apache.org