@Test public void testStartDownload() throws Exception { Response result = service.startDownload(ARTIFACT_NAME, VERSION_NUMBER); assertEquals(result.getStatus(), Response.Status.ACCEPTED.getStatusCode()); assertTrue(result.getEntity() instanceof DownloadToken); assertNotNull(((DownloadToken) result.getEntity()).getId()); verify(mockFacade).startDownload(createArtifact("codenvy"), version); }
@Test public void testStartDownloadShouldReturnConflictWhenDownloadStarted() throws Exception { doThrow(new DownloadAlreadyStartedException()) .when(mockFacade) .startDownload(artifact, version); Response result = service.startDownload(ARTIFACT_NAME, VERSION_NUMBER); assertEquals(result.getStatus(), Response.Status.CONFLICT.getStatusCode()); verify(mockFacade).startDownload(artifact, version); }
@Test public void testStartDownloadShouldReturnBadRequestIfVersionInvalid() throws Exception { Response result = service.startDownload(ARTIFACT_NAME, "1"); assertEquals(result.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); }
@Test public void testStartDownloadShouldReturnBadRequestIfArtifactInvalid() throws Exception { Response result = service.startDownload("no_name", null); assertEquals(result.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); }