use of org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl in project che by eclipse.
the class WorkspaceTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, EnvironmentRecipeImpl.class, ExtendedMachineImpl.class, SourceStorageImpl.class, ServerConf2Impl.class, StackImpl.class, CommandImpl.class, SnapshotImpl.class, RecipeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").setExceptionHandler(H2ExceptionHandler.class).build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new WorkspaceRepository());
bind(new TypeLiteral<TckRepository<StackImpl>>() {
}).toInstance(new StackRepository());
bind(WorkspaceDao.class).to(JpaWorkspaceDao.class);
bind(StackDao.class).to(JpaStackDao.class);
}
use of org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl in project che by eclipse.
the class StackDaoTest method shouldFindStacksWithSpecifiedTags.
@Test(dependsOnMethods = "shouldUpdateStack")
public void shouldFindStacksWithSpecifiedTags() throws Exception {
stacks[0].getTags().addAll(asList("search-tag1", "search-tag2"));
stacks[1].getTags().addAll(asList("search-tag1", "non-search-tag"));
stacks[2].getTags().addAll(asList("non-search-tag", "search-tag2"));
stacks[3].getTags().addAll(asList("search-tag1", "search-tag2", "another-tag"));
updateAll();
final List<StackImpl> found = stackDao.searchStacks(null, asList("search-tag1", "search-tag2"), 0, 0);
found.forEach(s -> Collections.sort(s.getTags()));
for (StackImpl stack : stacks) {
Collections.sort(stack.getTags());
}
assertEquals(new HashSet<>(found), new HashSet<>(asList(stacks[0], stacks[3])));
}
use of org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl in project che by eclipse.
the class StackDaoTest method shouldRemoveStack.
@Test(expectedExceptions = NotFoundException.class, dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingStack")
public void shouldRemoveStack() throws Exception {
final StackImpl stack = stacks[0];
stackDao.remove(stack.getId());
// Should throw an exception
stackDao.getById(stack.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl in project che by eclipse.
the class StackDaoTest method shouldThrowConflictExceptionWhenCreatingStackWithIdThatAlreadyExists.
@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenCreatingStackWithIdThatAlreadyExists() throws Exception {
final StackImpl stack = createStack(stacks[0].getId(), "new-name");
stackDao.create(stack);
}
use of org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl in project che by eclipse.
the class JpaStackDao method doRemove.
@Transactional(rollbackOn = { RuntimeException.class, ServerException.class })
protected void doRemove(String id) throws ServerException {
final EntityManager manager = managerProvider.get();
final StackImpl stack = manager.find(StackImpl.class, id);
if (stack != null) {
eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException();
manager.remove(stack);
manager.flush();
}
}
Aggregations