use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class UserDevfileManagerTest method shouldSendDevfileUpdatedEventOnUpdateDevfile.
@Test
public void shouldSendDevfileUpdatedEventOnUpdateDevfile() throws Exception {
// given
final UserDevfileImpl userDevfile = createUserDevfile();
when(userDevfileDao.update(any(UserDevfileImpl.class))).thenAnswer(invocationOnMock -> Optional.of(invocationOnMock.getArguments()[0]));
// when
userDevfileManager.updateUserDevfile(userDevfile);
// then
verify(eventService).publish(devfileUpdatedEventCaptor.capture());
assertEquals(userDevfile, devfileUpdatedEventCaptor.getValue().getUserDevfile());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class UserDevfileTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(UserImpl.class, AccountImpl.class, UserDevfileImpl.class, DevfileImpl.class, ActionImpl.class, CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, VolumeImpl.class).addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).setProperty("eclipselink.logging.level", "OFF").build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(UserDevfileDao.class).to(JpaUserDevfileDao.class);
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).toInstance(new JpaTckRepository<>(UserImpl.class));
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class UserDevfileDaoTest method shouldUpdateUserDevfile.
@Test
public void shouldUpdateUserDevfile() throws Exception {
// given
DevfileImpl newDevfile = TestObjectGenerator.createDevfile("newUpdate");
newDevfile.setApiVersion("V15.0");
newDevfile.setProjects(ImmutableList.of(new ProjectImpl("projectUp2", new SourceImpl("typeUp2", "http://location", "branch2", "point2", "tag2", "commit2", "sparseCheckoutDir2"), "path2")));
newDevfile.setComponents(ImmutableList.of(new ComponentImpl("type3", "id54")));
newDevfile.setCommands(ImmutableList.of(new CommandImpl(new CommandImpl("cmd1", Collections.singletonList(new ActionImpl("exe44", "compo2nent2", "run.sh", "/home/user/2", null, null)), Collections.singletonMap("attr1", "value1"), null))));
newDevfile.setAttributes(ImmutableMap.of("key2", "val34"));
newDevfile.setMetadata(new MetadataImpl("myNewName"));
final UserDevfileImpl update = devfiles[0];
update.setDevfile(newDevfile);
// when
userDevfileDaoDao.update(update);
// then
assertEquals(userDevfileDaoDao.getById(update.getId()), Optional.of(update));
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
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());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.
the class UserDevfileDaoTest method shouldGetUserDevfileById.
@Test
public void shouldGetUserDevfileById() throws Exception {
final UserDevfileImpl devfile = devfiles[0];
assertEquals(userDevfileDaoDao.getById(devfile.getId()), Optional.of(devfile));
}
Aggregations