Search in sources :

Example 11 with FactoryImpl

use of org.eclipse.che.api.factory.server.model.impl.FactoryImpl in project che by eclipse.

the class FactoryManager method saveFactory.

/**
     * Stores {@link Factory} instance and related set of {@link FactoryImage}.
     *
     * @param factory
     *         instance of factory which would be stored
     * @param images
     *         factory images which would be stored
     * @return factory which has been stored
     * @throws NullPointerException
     *         when {@code factory} is null
     * @throws ConflictException
     *         when any conflict occurs (e.g Factory with given name already exists for {@code creator})
     * @throws ServerException
     *         when any server errors occurs
     */
public Factory saveFactory(Factory factory, Set<FactoryImage> images) throws ConflictException, ServerException {
    requireNonNull(factory);
    final FactoryImpl newFactory = new FactoryImpl(factory, images);
    newFactory.setId(NameGenerator.generate("factory", 16));
    return factoryDao.create(newFactory);
}
Also used : FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl)

Example 12 with FactoryImpl

use of org.eclipse.che.api.factory.server.model.impl.FactoryImpl in project che by eclipse.

the class FactoryDaoTest method shouldFindFactoryByEmbeddedAttributes.

@Test(dependsOnMethods = "shouldUpdateFactory")
public void shouldFindFactoryByEmbeddedAttributes() throws Exception {
    final List<Pair<String, String>> attributes = ImmutableList.of(Pair.of("policies.match", "match"), Pair.of("policies.create", "perClick"), Pair.of("workspace.defaultEnv", "env1"));
    final FactoryImpl factory1 = factories[1];
    final FactoryImpl factory3 = factories[3];
    factory1.getPolicies().setCreate("perAccount");
    factory3.getPolicies().setMatch("update");
    factoryDao.update(factory1);
    factoryDao.update(factory3);
    final List<FactoryImpl> result = factoryDao.getByAttribute(factories.length, 0, attributes);
    assertEquals(new HashSet<>(result), ImmutableSet.of(factories[0], factories[2], factories[4]));
}
Also used : FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) Pair(org.eclipse.che.commons.lang.Pair) Test(org.testng.annotations.Test)

Example 13 with FactoryImpl

use of org.eclipse.che.api.factory.server.model.impl.FactoryImpl in project che by eclipse.

the class FactoryDaoTest method shouldGetFactoryById.

@Test
public void shouldGetFactoryById() throws Exception {
    final FactoryImpl factory = factories[0];
    assertEquals(factoryDao.getById(factory.getId()), factory);
}
Also used : FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) Test(org.testng.annotations.Test)

Aggregations

FactoryImpl (org.eclipse.che.api.factory.server.model.impl.FactoryImpl)13 Test (org.testng.annotations.Test)6 Transactional (com.google.inject.persist.Transactional)3 AuthorImpl (org.eclipse.che.api.factory.server.model.impl.AuthorImpl)3 EntityManager (javax.persistence.EntityManager)2 ActionImpl (org.eclipse.che.api.factory.server.model.impl.ActionImpl)2 ButtonAttributesImpl (org.eclipse.che.api.factory.server.model.impl.ButtonAttributesImpl)2 ButtonImpl (org.eclipse.che.api.factory.server.model.impl.ButtonImpl)2 PoliciesImpl (org.eclipse.che.api.factory.server.model.impl.PoliciesImpl)2 Pair (org.eclipse.che.commons.lang.Pair)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 StringJoiner (java.util.StringJoiner)1 NotFoundException (org.eclipse.che.api.core.NotFoundException)1 ServerException (org.eclipse.che.api.core.ServerException)1 FactoryImage (org.eclipse.che.api.factory.server.FactoryImage)1 IdeImpl (org.eclipse.che.api.factory.server.model.impl.IdeImpl)1 OnAppClosedImpl (org.eclipse.che.api.factory.server.model.impl.OnAppClosedImpl)1