Search in sources :

Example 1 with PoliciesImpl

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

the class FactoryDaoTest method shouldUpdateFactory.

// TODO fix after issue: https://github.com/eclipse/che/issues/2110
//    @Test(expectedExceptions = ConflictException.class)
//    public void shouldThrowConflictExceptionWhenCreatingFactoryWithExistingNameAndUserId() throws Exception {
//        final FactoryImpl factory = createFactory(10, users[0].getId());
//        final FactoryImpl existing = factories[0];
//        factory.getCreator().setUserId(existing.getCreator().getUserId());
//        factory.setName(existing.getName());
//        factoryDao.create(factory);
//    }
@Test
public void shouldUpdateFactory() throws Exception {
    final FactoryImpl update = factories[0];
    final String userId = update.getCreator().getUserId();
    update.setName("new-name");
    update.setV("5_0");
    final long currentTime = System.currentTimeMillis();
    update.setPolicies(new PoliciesImpl("ref", "match", "per-click", currentTime, currentTime + 1000));
    update.setCreator(new AuthorImpl(userId, currentTime));
    update.setButton(new ButtonImpl(new ButtonAttributesImpl("green", "icon", "opacity 0.9", true), Button.Type.NOLOGO));
    update.getIde().getOnAppClosed().getActions().add(new ActionImpl("remove file", ImmutableMap.of("file1", "/che/core/pom.xml")));
    update.getIde().getOnAppLoaded().getActions().add(new ActionImpl("edit file", ImmutableMap.of("file2", "/che/core/pom.xml")));
    update.getIde().getOnProjectsLoaded().getActions().add(new ActionImpl("open file", ImmutableMap.of("file2", "/che/pom.xml")));
    factoryDao.update(update);
    assertEquals(factoryDao.getById(update.getId()), update);
}
Also used : ActionImpl(org.eclipse.che.api.factory.server.model.impl.ActionImpl) ButtonImpl(org.eclipse.che.api.factory.server.model.impl.ButtonImpl) AuthorImpl(org.eclipse.che.api.factory.server.model.impl.AuthorImpl) PoliciesImpl(org.eclipse.che.api.factory.server.model.impl.PoliciesImpl) FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) ButtonAttributesImpl(org.eclipse.che.api.factory.server.model.impl.ButtonAttributesImpl) Test(org.testng.annotations.Test)

Example 2 with PoliciesImpl

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

the class FactoryDaoTest method createFactory.

private static FactoryImpl createFactory(int index, String userId) {
    final long timeMs = System.currentTimeMillis();
    final ButtonImpl factoryButton = new ButtonImpl(new ButtonAttributesImpl("red", "logo", "style", true), Button.Type.LOGO);
    final AuthorImpl creator = new AuthorImpl(userId, timeMs);
    final PoliciesImpl policies = new PoliciesImpl("referrer", "match", "perClick", timeMs, timeMs + 1000);
    final Set<FactoryImage> images = new HashSet<>();
    final List<ActionImpl> a1 = new ArrayList<>(singletonList(new ActionImpl("id" + index, ImmutableMap.of("key1", "value1"))));
    final OnAppLoadedImpl onAppLoaded = new OnAppLoadedImpl(a1);
    final List<ActionImpl> a2 = new ArrayList<>(singletonList(new ActionImpl("id" + index, ImmutableMap.of("key2", "value2"))));
    final OnProjectsLoadedImpl onProjectsLoaded = new OnProjectsLoadedImpl(a2);
    final List<ActionImpl> a3 = new ArrayList<>(singletonList(new ActionImpl("id" + index, ImmutableMap.of("key3", "value3"))));
    final OnAppClosedImpl onAppClosed = new OnAppClosedImpl(a3);
    final IdeImpl ide = new IdeImpl(onAppLoaded, onProjectsLoaded, onAppClosed);
    final FactoryImpl factory = FactoryImpl.builder().generateId().setVersion("4_0").setName("factoryName" + index).setButton(factoryButton).setCreator(creator).setPolicies(policies).setImages(images).setIde(ide).build();
    factory.setWorkspace(createWorkspaceConfig(index));
    return factory;
}
Also used : OnAppLoadedImpl(org.eclipse.che.api.factory.server.model.impl.OnAppLoadedImpl) OnProjectsLoadedImpl(org.eclipse.che.api.factory.server.model.impl.OnProjectsLoadedImpl) ArrayList(java.util.ArrayList) FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) FactoryImage(org.eclipse.che.api.factory.server.FactoryImage) IdeImpl(org.eclipse.che.api.factory.server.model.impl.IdeImpl) ActionImpl(org.eclipse.che.api.factory.server.model.impl.ActionImpl) ButtonImpl(org.eclipse.che.api.factory.server.model.impl.ButtonImpl) AuthorImpl(org.eclipse.che.api.factory.server.model.impl.AuthorImpl) PoliciesImpl(org.eclipse.che.api.factory.server.model.impl.PoliciesImpl) ButtonAttributesImpl(org.eclipse.che.api.factory.server.model.impl.ButtonAttributesImpl) HashSet(java.util.HashSet) OnAppClosedImpl(org.eclipse.che.api.factory.server.model.impl.OnAppClosedImpl)

Aggregations

ActionImpl (org.eclipse.che.api.factory.server.model.impl.ActionImpl)2 AuthorImpl (org.eclipse.che.api.factory.server.model.impl.AuthorImpl)2 ButtonAttributesImpl (org.eclipse.che.api.factory.server.model.impl.ButtonAttributesImpl)2 ButtonImpl (org.eclipse.che.api.factory.server.model.impl.ButtonImpl)2 FactoryImpl (org.eclipse.che.api.factory.server.model.impl.FactoryImpl)2 PoliciesImpl (org.eclipse.che.api.factory.server.model.impl.PoliciesImpl)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)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 OnAppLoadedImpl (org.eclipse.che.api.factory.server.model.impl.OnAppLoadedImpl)1 OnProjectsLoadedImpl (org.eclipse.che.api.factory.server.model.impl.OnProjectsLoadedImpl)1 Test (org.testng.annotations.Test)1