Search in sources :

Example 1 with SnapshotImpl

use of org.eclipse.che.api.machine.server.model.impl.SnapshotImpl in project che by eclipse.

the class SnapshotDaoTest method shouldNotSaveSnapshotWithReservedId.

@Test(expectedExceptions = SnapshotException.class)
public void shouldNotSaveSnapshotWithReservedId() throws Exception {
    final SnapshotImpl snapshot = snapshots[0];
    snapshot.setWorkspaceId("new-workspace");
    snapshot.setEnvName("new-env");
    snapshot.setMachineName("new-machine");
    snapshotDao.saveSnapshot(snapshot);
}
Also used : SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) Test(org.testng.annotations.Test)

Example 2 with SnapshotImpl

use of org.eclipse.che.api.machine.server.model.impl.SnapshotImpl in project che by eclipse.

the class CheEnvironmentEngineTest method shouldBeAbleToRemoveSnapshot.

@Test
public void shouldBeAbleToRemoveSnapshot() throws Exception {
    // given
    SnapshotImpl snapshot = mock(SnapshotImpl.class);
    MachineSourceImpl machineSource = mock(MachineSourceImpl.class);
    when(snapshot.getType()).thenReturn("docker");
    when(snapshot.getMachineSource()).thenReturn(machineSource);
    // when
    engine.removeSnapshot(snapshot);
    // then
    verify(instanceProvider).removeInstanceSnapshot(machineSource);
}
Also used : SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) MachineSourceImpl(org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl) Test(org.testng.annotations.Test)

Example 3 with SnapshotImpl

use of org.eclipse.che.api.machine.server.model.impl.SnapshotImpl in project che by eclipse.

the class JpaTckModule method configure.

@Override
protected void configure() {
    install(new JpaPersistModule("main"));
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(H2TestHelper.inMemoryDefault(), "che-schema"));
    bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
    bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
    }).toInstance(new JpaTckRepository<>(RecipeImpl.class));
    bind(new TypeLiteral<TckRepository<SnapshotImpl>>() {
    }).toInstance(new JpaTckRepository<>(SnapshotImpl.class));
    bind(new TypeLiteral<TckRepository<Workspace>>() {
    }).toInstance(new TestWorkspacesTckRepository());
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(RecipeDao.class).to(JpaRecipeDao.class);
    bind(SnapshotDao.class).to(JpaSnapshotDao.class);
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) JpaPersistModule(com.google.inject.persist.jpa.JpaPersistModule) 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) SnapshotDao(org.eclipse.che.api.machine.server.spi.SnapshotDao) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) RecipeDao(org.eclipse.che.api.machine.server.spi.RecipeDao) RecipeImpl(org.eclipse.che.api.machine.server.recipe.RecipeImpl) Workspace(org.eclipse.che.api.core.model.workspace.Workspace)

Example 4 with SnapshotImpl

use of org.eclipse.che.api.machine.server.model.impl.SnapshotImpl in project che by eclipse.

the class SnapshotDaoTest method shouldRemoveSnapshot.

@Test(expectedExceptions = NotFoundException.class, dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingSnapshot")
public void shouldRemoveSnapshot() throws Exception {
    final SnapshotImpl snapshot = snapshots[0];
    try {
        snapshotDao.removeSnapshot(snapshot.getId());
    } catch (NotFoundException x) {
        fail("Should remove snapshot");
    }
    snapshotDao.getSnapshot(snapshot.getId());
}
Also used : SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) NotFoundException(org.eclipse.che.api.core.NotFoundException) Test(org.testng.annotations.Test)

Example 5 with SnapshotImpl

use of org.eclipse.che.api.machine.server.model.impl.SnapshotImpl in project che by eclipse.

the class SnapshotDaoTest method shouldNotSaveSnapshotForMachineIfSnapshotForSuchMachineAlreadyExists.

@Test(expectedExceptions = SnapshotException.class)
public void shouldNotSaveSnapshotForMachineIfSnapshotForSuchMachineAlreadyExists() throws Exception {
    final SnapshotImpl snapshot = snapshots[0];
    snapshot.setId("new-id");
    snapshotDao.saveSnapshot(snapshot);
}
Also used : SnapshotImpl(org.eclipse.che.api.machine.server.model.impl.SnapshotImpl) Test(org.testng.annotations.Test)

Aggregations

SnapshotImpl (org.eclipse.che.api.machine.server.model.impl.SnapshotImpl)31 Test (org.testng.annotations.Test)22 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)13 MachineSourceImpl (org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl)10 NotFoundException (org.eclipse.che.api.core.NotFoundException)6 ServerException (org.eclipse.che.api.core.ServerException)5 SnapshotException (org.eclipse.che.api.machine.server.exception.SnapshotException)4 Instance (org.eclipse.che.api.machine.server.spi.Instance)4 ArrayList (java.util.ArrayList)3 ConflictException (org.eclipse.che.api.core.ConflictException)3 Workspace (org.eclipse.che.api.core.model.workspace.Workspace)3 EnvironmentException (org.eclipse.che.api.environment.server.exception.EnvironmentException)3 EnvironmentNotRunningException (org.eclipse.che.api.environment.server.exception.EnvironmentNotRunningException)3 SourceNotFoundException (org.eclipse.che.api.machine.server.exception.SourceNotFoundException)3 SnapshotDao (org.eclipse.che.api.machine.server.spi.SnapshotDao)3 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)3 Matchers.anyString (org.mockito.Matchers.anyString)3 TypeLiteral (com.google.inject.TypeLiteral)2 Transactional (com.google.inject.persist.Transactional)2 IOException (java.io.IOException)2