You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dlab.apache.org by GitBox <gi...@apache.org> on 2020/09/01 10:29:54 UTC

[GitHub] [incubator-dlab] ofuks commented on a change in pull request #879: [DLAB] Project Resource UT

ofuks commented on a change in pull request #879:
URL: https://github.com/apache/incubator-dlab/pull/879#discussion_r481038109



##########
File path: services/self-service/src/test/java/com/epam/dlab/backendapi/resources/ProjectResourceTest.java
##########
@@ -48,83 +56,129 @@
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-
 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 final static String PROJECT_NAME = "DLAB";

Review comment:
       Please follow the Java constant convention **private static final**, not **private final static**




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@dlab.apache.org
For additional commands, e-mail: dev-help@dlab.apache.org