use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.
the class DefaultEditorProvisionerTest method shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchByReference.
@Test
public void shouldNotProvisionDefaultPluginIfDevfileAlreadyContainsSuchByReference() throws Exception {
// given
provisioner = new DefaultEditorProvisioner(EDITOR_REF, TERMINAL_PLUGIN_REF, "", fqnParser, pluginFQNParser);
DevfileImpl devfile = new DevfileImpl();
String meta = "apiVersion: v2\n" + "publisher: " + EDITOR_PUBLISHER + "\n" + "name: " + TERMINAL_PLUGIN_NAME + "\n" + "version: " + TERMINAL_PLUGIN_VERSION + "\n" + "type: Che Plugin";
ComponentImpl myTerminal = new ComponentImpl(PLUGIN_COMPONENT_TYPE, null, "https://myregistry.com/abc/meta.yaml", null, null, null);
when(fileContentProvider.fetchContent(anyString())).thenReturn(meta);
devfile.getComponents().add(myTerminal);
// when
provisioner.apply(devfile, fileContentProvider);
// then
List<ComponentImpl> components = devfile.getComponents();
assertEquals(components.size(), 2);
assertTrue(components.contains(new ComponentImpl(EDITOR_COMPONENT_TYPE, EDITOR_REF)));
assertTrue(components.contains(myTerminal));
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.
the class DevfileConverterTest method shouldUseDevfileNameForWorkspaceNameDuringConvertingDevfileToWorkspaceConfig.
@Test
public void shouldUseDevfileNameForWorkspaceNameDuringConvertingDevfileToWorkspaceConfig() throws Exception {
// given
FileContentProvider fileContentProvider = mock(FileContentProvider.class);
DevfileImpl devfile = newDevfile("petclinic");
// when
WorkspaceConfigImpl workspaceConfig = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
// then
assertEquals(workspaceConfig.getName(), "petclinic");
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.
the class DevfileConverterTest method shouldThrowAnExceptionIfDevfileApiVersionIsNotSupportedDuringConvertingDevfileToWorkspaceConfig.
@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Provided Devfile has unsupported version '1\\.0\\.0-non-supported'. The following versions are supported: .*")
public void shouldThrowAnExceptionIfDevfileApiVersionIsNotSupportedDuringConvertingDevfileToWorkspaceConfig() throws Exception {
// given
FileContentProvider fileContentProvider = mock(FileContentProvider.class);
DevfileImpl devfile = new DevfileImpl();
devfile.setApiVersion("1.0.0-non-supported");
devfile.setName("petclinic");
// when
devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.
the class DevfileConverterTest method shouldConvertCommandsDuringConvertingDevfileToWorkspaceConfig.
@Test
public void shouldConvertCommandsDuringConvertingDevfileToWorkspaceConfig() throws Exception {
// given
FileContentProvider fileContentProvider = mock(FileContentProvider.class);
DevfileImpl devfile = newDevfile("petclinic");
CommandImpl devfileCommand = mock(CommandImpl.class);
devfile.getCommands().add(devfileCommand);
org.eclipse.che.api.workspace.server.model.impl.CommandImpl workspaceCommand = mock(org.eclipse.che.api.workspace.server.model.impl.CommandImpl.class);
when(commandConverter.toWorkspaceCommand(any(), any())).thenReturn(workspaceCommand);
// when
WorkspaceConfigImpl workspaceConfig = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
// then
assertEquals(workspaceConfig.getCommands().size(), 1);
assertSame(workspaceConfig.getCommands().get(0), workspaceCommand);
}
use of org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl in project che-server by eclipse-che.
the class DevfileConverterTest method shouldInvokeDefaultEditorProvisionerDuringConvertingDevfileToWorkrspaceConfig.
@Test
public void shouldInvokeDefaultEditorProvisionerDuringConvertingDevfileToWorkrspaceConfig() throws Exception {
// given
FileContentProvider fileContentProvider = mock(FileContentProvider.class);
DevfileImpl devfile = newDevfile("petclinic");
// when
devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
// then
verify(defaultEditorToolApplier).apply(devfile, fileContentProvider);
}
Aggregations