Search in sources :

Example 31 with FileContentProvider

use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.

the class GithubAuthorizingFileContentProviderTest method shouldExpandRelativePaths.

@Test
public void shouldExpandRelativePaths() throws Exception {
    URLFetcher urlFetcher = Mockito.mock(URLFetcher.class);
    GithubUrl githubUrl = new GithubUrl().withUsername("eclipse").withRepository("che");
    FileContentProvider fileContentProvider = new GithubAuthorizingFileContentProvider(githubUrl, urlFetcher, gitCredentialManager, personalAccessTokenManager);
    fileContentProvider.fetchContent("devfile.yaml");
    verify(urlFetcher).fetch(eq("https://raw.githubusercontent.com/eclipse/che/HEAD/devfile.yaml"));
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) URLFetcher(org.eclipse.che.api.workspace.server.devfile.URLFetcher) Test(org.testng.annotations.Test)

Example 32 with FileContentProvider

use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.

the class DevfileConverterTest method shouldProvisionDevfileAttributesAsConfigAttributesDuringConvertingDevfileToWorkspaceConfig.

@Test
public void shouldProvisionDevfileAttributesAsConfigAttributesDuringConvertingDevfileToWorkspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    Map<String, String> devfileAttributes = new HashMap<>();
    devfileAttributes.put(PERSIST_VOLUMES_ATTRIBUTE, "false");
    devfileAttributes.put("anotherAttribute", "value");
    DevfileImpl devfile = newDevfile("petclinic");
    devfile.getAttributes().putAll(devfileAttributes);
    // when
    WorkspaceConfigImpl config = devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
    // then
    assertEquals(config.getAttributes(), devfileAttributes);
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) HashMap(java.util.HashMap) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test)

Example 33 with FileContentProvider

use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.

the class DevfileConverterTest method shouldThrowAnExceptionIfDevfileApiVersionIsMissingDuringConvertingDevfileToWorkspaceConfig.

@Test(expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "Provided Devfile has no API version specified")
public void shouldThrowAnExceptionIfDevfileApiVersionIsMissingDuringConvertingDevfileToWorkspaceConfig() throws Exception {
    // given
    FileContentProvider fileContentProvider = mock(FileContentProvider.class);
    DevfileImpl devfile = new DevfileImpl();
    devfile.setName("petclinic");
    // when
    devfileConverter.devFileToWorkspaceConfig(devfile, fileContentProvider);
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 34 with FileContentProvider

use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.

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);
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) Test(org.testng.annotations.Test)

Example 35 with FileContentProvider

use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.

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");
}
Also used : FileContentProvider(org.eclipse.che.api.workspace.server.devfile.FileContentProvider) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test)

Aggregations

FileContentProvider (org.eclipse.che.api.workspace.server.devfile.FileContentProvider)38 Test (org.testng.annotations.Test)30 DevfileImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl)18 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)14 URLFetcher (org.eclipse.che.api.workspace.server.devfile.URLFetcher)10 DevfileException (org.eclipse.che.api.workspace.server.devfile.exception.DevfileException)8 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)8 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)6 Inject (javax.inject.Inject)6 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Named (javax.inject.Named)4 DevfileLocation (org.eclipse.che.api.factory.server.urlfactory.RemoteFactoryUrl.DevfileLocation)4 EDITOR_COMPONENT_TYPE (org.eclipse.che.api.workspace.server.devfile.Constants.EDITOR_COMPONENT_TYPE)4 ComponentFQNParser (org.eclipse.che.api.workspace.server.devfile.convert.component.ComponentFQNParser)4 ExtendedPluginFQN (org.eclipse.che.api.workspace.server.wsplugins.model.ExtendedPluginFQN)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 String.format (java.lang.String.format)3 ComponentToWorkspaceApplier (org.eclipse.che.api.workspace.server.devfile.convert.component.ComponentToWorkspaceApplier)3