use of org.eclipse.che.api.core.model.workspace.devfile.UserDevfile in project che-server by eclipse-che.
the class UserDevfileManagerTest method shouldGetUserDevfileById.
@Test
public void shouldGetUserDevfileById() throws Exception {
// given
final Optional<UserDevfile> toFetch = Optional.of(createUserDevfile());
when(userDevfileDao.getById(eq("id123"))).thenReturn(toFetch);
// when
final UserDevfile fetched = userDevfileManager.getById("id123");
// then
assertEquals(fetched, toFetch.get());
verify(userDevfileDao).getById("id123");
}
use of org.eclipse.che.api.core.model.workspace.devfile.UserDevfile in project che-server by eclipse-che.
the class UserDevfileManagerTest method shouldGenerateUserDevfileIdOnCreation.
@Test
public void shouldGenerateUserDevfileIdOnCreation() throws Exception {
// given
final UserDevfileImpl userDevfile = new UserDevfileImpl(null, TEST_ACCOUNT, createUserDevfile());
when(userDevfileDao.create(any(UserDevfileImpl.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
// when
UserDevfile actual = userDevfileManager.createDevfile(userDevfile);
// then
verify(userDevfileDao).create(userDevfileArgumentCaptor.capture());
assertFalse(isNullOrEmpty(userDevfileArgumentCaptor.getValue().getId()));
assertEquals(new UserDevfileImpl(null, TEST_ACCOUNT, actual), userDevfile);
}
use of org.eclipse.che.api.core.model.workspace.devfile.UserDevfile in project che-server by eclipse-che.
the class UserDevfileManagerTest method shouldBeAbleToGetUserDevfilesAvailableToUser.
@Test
public void shouldBeAbleToGetUserDevfilesAvailableToUser() throws ServerException {
// given
final UserDevfileImpl userDevfile = createUserDevfile();
final UserDevfileImpl userDevfile2 = createUserDevfile();
when(userDevfileDao.getDevfiles(2, 30, Collections.emptyList(), Collections.emptyList())).thenReturn(new Page<>(asList(userDevfile, userDevfile2), 0, 2, 2));
// when
Page<UserDevfile> actual = userDevfileManager.getUserDevfiles(2, 30, Collections.emptyList(), Collections.emptyList());
// then
assertEquals(actual.getItems().size(), 2);
}
use of org.eclipse.che.api.core.model.workspace.devfile.UserDevfile in project che-server by eclipse-che.
the class UserDevfileManagerTest method shouldSendDevfileCreatedEventOnCreation.
@Test
public void shouldSendDevfileCreatedEventOnCreation() throws Exception {
// given
final UserDevfileImpl userDevfile = new UserDevfileImpl(null, TEST_ACCOUNT, createUserDevfile());
when(userDevfileDao.create(any(UserDevfileImpl.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
// when
UserDevfile expected = userDevfileManager.createDevfile(userDevfile);
// then
verify(eventService).publish(devfileCreatedEventCaptor.capture());
assertEquals(expected, devfileCreatedEventCaptor.getValue().getUserDevfile());
}
use of org.eclipse.che.api.core.model.workspace.devfile.UserDevfile in project che-server by eclipse-che.
the class UserDevfileDaoTest method shouldNotUpdateWorkspaceWhichDoesNotExist.
@Test
public void shouldNotUpdateWorkspaceWhichDoesNotExist() throws Exception {
// given
final UserDevfileImpl userDevfile = devfiles[0];
userDevfile.setId("non-existing-devfile");
// when
Optional<UserDevfile> result = userDevfileDaoDao.update(userDevfile);
// then
assertFalse(result.isPresent());
}
Aggregations