Search in sources :

Example 1 with RecipeImpl

use of org.eclipse.che.api.machine.server.recipe.RecipeImpl in project che by eclipse.

the class RecipeTypeAdapter method deserialize.

@Override
public Recipe deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException {
    final RecipeImpl recipe = new RecipeImpl();
    final JsonObject recipeObj = element.getAsJsonObject();
    recipe.setType(recipeObj.get("type") == null ? null : recipeObj.get("type").getAsString());
    recipe.setScript(recipeObj.get("script") == null ? null : recipeObj.get("script").getAsString());
    return recipe;
}
Also used : RecipeImpl(org.eclipse.che.api.machine.server.recipe.RecipeImpl) JsonObject(com.google.gson.JsonObject)

Example 2 with RecipeImpl

use of org.eclipse.che.api.machine.server.recipe.RecipeImpl 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 3 with RecipeImpl

use of org.eclipse.che.api.machine.server.recipe.RecipeImpl in project che by eclipse.

the class RecipeDaoTest method shouldUpdateRecipe.

@Test
public void shouldUpdateRecipe() throws Exception {
    final RecipeImpl update = recipes.get(0).withName("updatedName");
    assertEquals(recipeDao.update(update), update);
}
Also used : RecipeImpl(org.eclipse.che.api.machine.server.recipe.RecipeImpl) Test(org.testng.annotations.Test)

Example 4 with RecipeImpl

use of org.eclipse.che.api.machine.server.recipe.RecipeImpl in project che by eclipse.

the class RecipeDaoTest method shouldNotRemoveRecipeWhenSubscriberThrowsExceptionOnRecipeRemoving.

@Test(dependsOnMethods = "shouldGetRecipeById")
public void shouldNotRemoveRecipeWhenSubscriberThrowsExceptionOnRecipeRemoving() throws Exception {
    final RecipeImpl recipe = recipes.get(0);
    CascadeEventSubscriber<BeforeRecipeRemovedEvent> subscriber = mockCascadeEventSubscriber();
    doThrow(new ServerException("error")).when(subscriber).onCascadeEvent(any());
    eventService.subscribe(subscriber, BeforeRecipeRemovedEvent.class);
    try {
        recipeDao.remove(recipe.getId());
        fail("RecipeDao#remove had to throw server exception");
    } catch (ServerException ignored) {
    }
    assertEquals(recipeDao.getById(recipe.getId()), recipe);
    eventService.unsubscribe(subscriber, BeforeRecipeRemovedEvent.class);
}
Also used : ServerException(org.eclipse.che.api.core.ServerException) RecipeImpl(org.eclipse.che.api.machine.server.recipe.RecipeImpl) BeforeRecipeRemovedEvent(org.eclipse.che.api.machine.server.event.BeforeRecipeRemovedEvent) Test(org.testng.annotations.Test)

Example 5 with RecipeImpl

use of org.eclipse.che.api.machine.server.recipe.RecipeImpl in project che by eclipse.

the class RecipeDaoTest method shouldGetRecipeById.

@Test
public void shouldGetRecipeById() throws Exception {
    final RecipeImpl recipe = recipes.get(0);
    assertEquals(recipeDao.getById(recipe.getId()), recipe);
}
Also used : RecipeImpl(org.eclipse.che.api.machine.server.recipe.RecipeImpl) Test(org.testng.annotations.Test)

Aggregations

RecipeImpl (org.eclipse.che.api.machine.server.recipe.RecipeImpl)18 Test (org.testng.annotations.Test)8 Transactional (com.google.inject.persist.Transactional)4 EntityManager (javax.persistence.EntityManager)4 ServerException (org.eclipse.che.api.core.ServerException)3 TypeLiteral (com.google.inject.TypeLiteral)2 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 Workspace (org.eclipse.che.api.core.model.workspace.Workspace)2 BeforeRecipeRemovedEvent (org.eclipse.che.api.machine.server.event.BeforeRecipeRemovedEvent)2 SnapshotImpl (org.eclipse.che.api.machine.server.model.impl.SnapshotImpl)2 RecipeDao (org.eclipse.che.api.machine.server.spi.RecipeDao)2 SnapshotDao (org.eclipse.che.api.machine.server.spi.SnapshotDao)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 JsonObject (com.google.gson.JsonObject)1 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 URI (java.net.URI)1