Search in sources :

Example 91 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DevfileParserTest method testValidateAndParse.

@Test
public void testValidateAndParse() throws Exception {
    // when
    DevfileImpl parsed = devfileParser.parseYaml(DEVFILE_YAML_CONTENT);
    // then
    assertEquals(parsed, devfile);
    verify(yamlMapper).treeToValue(devfileJsonNode, DevfileImpl.class);
    verify(schemaValidator).validate(eq(devfileJsonNode));
    verify(integrityValidator).validateDevfile(devfile);
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 92 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DefaultEditorProvisionerTest method shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny.

@Test
public void shouldProvisionDefaultEditorWithPluginsWhenDevfileDoNotHaveAny() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF + "," + COMMAND_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 3);
    assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, COMMAND_PLUGIN_REF)));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF)));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 93 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class DefaultEditorProvisionerTest method shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne.

@Test
public void shouldProvisionDefaultPluginIfDevfileAlreadyContainPluginWithNameWhichStartWithDefaultOne() throws Exception {
    // given
    provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
    DevfileImpl devfile = new DevfileImpl();
    ComponentImpl pluginWithNameSimilarToDefault = new ComponentImpl(PLUGIN_COMPONENT_TYPE, EDITOR_PUBLISHER + "/" + TERMINAL_PLUGIN_NAME + "-dummy/latest");
    devfile.getComponents().add(pluginWithNameSimilarToDefault);
    // when
    provisioner.apply(devfile, fileContentProvider);
    // then
    List<ComponentImpl> components = devfile.getComponents();
    assertEquals(components.size(), 3);
    assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
    assertTrue(components.contains(new ComponentImpl(PLUGIN_COMPONENT_TYPE, TERMINAL_PLUGIN_REF)));
    assertTrue(components.contains(pluginWithNameSimilarToDefault));
}
Also used : DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 94 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class UserDevfileDaoTest method shouldUpdateUserDevfile.

@Test
public void shouldUpdateUserDevfile() throws Exception {
    // given
    DevfileImpl newDevfile = TestObjectGenerator.createDevfile("newUpdate");
    newDevfile.setApiVersion("V15.0");
    newDevfile.setProjects(ImmutableList.of(new ProjectImpl("projectUp2", new SourceImpl("typeUp2", "http://location", "branch2", "point2", "tag2", "commit2", "sparseCheckoutDir2"), "path2")));
    newDevfile.setComponents(ImmutableList.of(new ComponentImpl("type3", "id54")));
    newDevfile.setCommands(ImmutableList.of(new CommandImpl(new CommandImpl("cmd1", Collections.singletonList(new ActionImpl("exe44", "compo2nent2", "run.sh", "/home/user/2", null, null)), Collections.singletonMap("attr1", "value1"), null))));
    newDevfile.setAttributes(ImmutableMap.of("key2", "val34"));
    newDevfile.setMetadata(new MetadataImpl("myNewName"));
    final UserDevfileImpl update = devfiles[0];
    update.setDevfile(newDevfile);
    // when
    userDevfileDaoDao.update(update);
    // then
    assertEquals(userDevfileDaoDao.getById(update.getId()), Optional.of(update));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) MetadataImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 95 with DevfileImpl

use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.

the class UserDevfileDaoTest method shouldCreateUserDevfileWithEmptyMataName.

@Test
public void shouldCreateUserDevfileWithEmptyMataName() throws Exception {
    // given
    final UserDevfileImpl devfile = createUserDevfile(accounts[0]);
    DevfileImpl newDevfile = new DevfileImpl(devfile.getDevfile());
    MetadataImpl newMeta = new MetadataImpl();
    newMeta.setGenerateName("gener-");
    newDevfile.setMetadata(newMeta);
    devfile.setDevfile(newDevfile);
    // when
    userDevfileDaoDao.create(devfile);
    Optional<UserDevfile> devfileOptional = userDevfileDaoDao.getById(devfile.getId());
    assertTrue(devfileOptional.isPresent());
    UserDevfile actual = devfileOptional.get();
    assertNull(actual.getDevfile().getMetadata().getName());
    assertNotNull(actual.getDevfile().getMetadata().getGenerateName());
    assertEquals(devfileOptional, Optional.of(new UserDevfileImpl(devfile)));
}
Also used : MetadataImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl) UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) TestObjectGenerator.createUserDevfile(org.eclipse.che.api.devfile.server.TestObjectGenerator.createUserDevfile) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) Test(org.testng.annotations.Test)

Aggregations

DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)162 Test (org.testng.annotations.Test)126 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)76 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)22 FileContentProvider (org.eclipse.che.api.workspace.server.devfile.FileContentProvider)20 MetadataImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl)20 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)18 ActionImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl)16 ProjectImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl)16 Container (io.fabric8.kubernetes.api.model.Container)14 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl)14 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)14 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)14 EndpointImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl)12 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)10 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 Secret (io.fabric8.kubernetes.api.model.Secret)10 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)10 HashMap (java.util.HashMap)10 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)10