use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class DevfileServiceTest method shouldBeAbleToUpdateUserDevfile.
@Test
public void shouldBeAbleToUpdateUserDevfile() throws Exception {
// given
final UserDevfileDto devfileDto = TestObjectGenerator.createUserDevfileDto();
final UserDevfileImpl userDevfileImpl = new UserDevfileImpl(devfileDto, TEST_ACCOUNT);
when(userDevfileManager.updateUserDevfile(any(UserDevfile.class))).thenReturn(userDevfileImpl);
// when
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType(APPLICATION_JSON).body(DtoFactory.getInstance().toJson(devfileDto)).when().put(SECURE_PATH + "/devfile/" + devfileDto.getId());
// then
assertEquals(response.getStatusCode(), 200);
assertEquals(new UserDevfileImpl(unwrapDto(response, UserDevfileDto.class), TEST_ACCOUNT), userDevfileImpl);
verify(userDevfileManager).updateUserDevfile(devfileDto);
verify(linksInjector).injectLinks(any(), any());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class DevfileServiceTest method shouldGetUserDevfilesAvailableToUser.
@Test
public void shouldGetUserDevfilesAvailableToUser() throws Exception {
// given
final UserDevfileDto devfileDto = TestObjectGenerator.createUserDevfileDto();
final UserDevfileImpl userDevfileImpl = new UserDevfileImpl(devfileDto, TEST_ACCOUNT);
doReturn(new Page<>(ImmutableList.of(userDevfileImpl), 0, 1, 1)).when(userDevfileManager).getUserDevfiles(anyInt(), anyInt(), anyList(), anyList());
// when
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().get(SECURE_PATH + "/devfile/search").then().extract().response();
// then
assertEquals(response.getStatusCode(), 200);
final List<UserDevfileDto> res = unwrapDtoList(response, UserDevfileDto.class);
assertEquals(res.size(), 1);
assertEquals(res.get(0).withLinks(emptyList()), devfileDto);
verify(userDevfileManager).getUserDevfiles(eq(30), eq(0), anyList(), anyList());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class DevfileServiceTest method shouldGetUserDevfileById.
@Test
public void shouldGetUserDevfileById() throws Exception {
final UserDevfileImpl userDevfile = TestObjectGenerator.createUserDevfile();
when(userDevfileManager.getById(eq("id-22323"))).thenReturn(userDevfile);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().get(SECURE_PATH + "/devfile/id-22323").then().extract().response();
assertEquals(response.getStatusCode(), 200);
assertEquals(new UserDevfileImpl(unwrapDto(response, UserDevfileDto.class), TEST_ACCOUNT), userDevfile);
verify(userDevfileManager).getById(eq("id-22323"));
verify(linksInjector).injectLinks(any(), any());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class UserDevfileManagerTest method shouldRemoveUserDevfile.
@Test
public void shouldRemoveUserDevfile() throws Exception {
// given
final UserDevfileImpl userDevfile = createUserDevfile();
// when
userDevfileManager.removeUserDevfile(userDevfile.getId());
// then
verify(userDevfileDao).remove(userDevfile.getId());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class UserDevfileManagerTest method shouldThrowNotFoundIfUserDevfileIsNotFoundOnUpdate.
@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundIfUserDevfileIsNotFoundOnUpdate() throws Exception {
// given
final UserDevfileImpl userDevfile = createUserDevfile();
Mockito.doReturn(Optional.empty()).when(userDevfileDao).update(any(UserDevfileImpl.class));
// when
userDevfileManager.updateUserDevfile(userDevfile);
}
Aggregations