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);
}
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]));
}
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);
}
Aggregations