Search in sources :

Example 1 with StackImpl

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);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) AccountImpl(org.eclipse.che.account.spi.AccountImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) StackDao(org.eclipse.che.api.workspace.server.spi.StackDao) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao)

Example 2 with StackImpl

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])));
}
Also used : StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) Test(org.testng.annotations.Test)

Example 3 with StackImpl

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());
}
Also used : StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) Test(org.testng.annotations.Test)

Example 4 with StackImpl

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);
}
Also used : StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) Test(org.testng.annotations.Test)

Example 5 with StackImpl

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();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) StackImpl(org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl) BeforeStackRemovedEvent(org.eclipse.che.api.workspace.server.event.BeforeStackRemovedEvent) Transactional(com.google.inject.persist.Transactional)

Aggregations

StackImpl (org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl)26 Test (org.testng.annotations.Test)15 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 GenerateLink (org.eclipse.che.api.core.rest.annotations.GenerateLink)5 Response (com.jayway.restassured.response.Response)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 StackIcon (org.eclipse.che.api.workspace.server.stack.image.StackIcon)4 Consumes (javax.ws.rs.Consumes)3 NotFoundException (org.eclipse.che.api.core.NotFoundException)3 StackDto (org.eclipse.che.api.workspace.shared.dto.stack.StackDto)3 TypeLiteral (com.google.inject.TypeLiteral)2 Transactional (com.google.inject.persist.Transactional)2 EntityManager (javax.persistence.EntityManager)2 POST (javax.ws.rs.POST)2 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 ConflictException (org.eclipse.che.api.core.ConflictException)2 ServerException (org.eclipse.che.api.core.ServerException)2 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)2