use of org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto in project che-server by eclipse-che.
the class BitbucketServerAuthorizingFactoryParametersResolverTest method shouldSetScmInfoIntoDevfileV2.
@Test
public void shouldSetScmInfoIntoDevfileV2() throws Exception {
String bitbucketUrl = "http://bitbucket.2mcl.com/scm/test/repo.git?at=foobar";
FactoryDevfileV2Dto computedFactory = generateDevfileV2Factory();
when(urlFactoryBuilder.createFactoryFromDevfile(any(RemoteFactoryUrl.class), any(), anyMap())).thenReturn(Optional.of(computedFactory));
Map<String, String> params = ImmutableMap.of(URL_PARAMETER_NAME, bitbucketUrl);
// when
FactoryDevfileV2Dto factory = (FactoryDevfileV2Dto) bitbucketServerFactoryParametersResolver.createFactory(params);
// then
ScmInfo scmInfo = factory.getScmInfo();
assertNotNull(scmInfo);
assertEquals(scmInfo.getScmProviderName(), "bitbucket");
assertEquals(scmInfo.getRepositoryUrl(), "http://bitbucket.2mcl.com/scm/test/repo.git");
assertEquals(scmInfo.getBranch(), "foobar");
}
use of org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto in project devspaces-images by redhat-developer.
the class URLFactoryBuilderTest method testDevfileV2.
@Test
public void testDevfileV2() throws ApiException, DevfileException {
String myLocation = "http://foo-location/";
Map<String, Object> devfileAsMap = Map.of("hello", "there", "how", "are", "you", "?");
JsonNode devfile = new ObjectNode(JsonNodeFactory.instance);
when(devfileParser.parseYamlRaw(anyString())).thenReturn(devfile);
when(devfileParser.convertYamlToMap(devfile)).thenReturn(devfileAsMap);
when(devfileVersionDetector.devfileMajorVersion(devfile)).thenReturn(2);
FactoryMetaDto factory = urlFactoryBuilder.createFactoryFromDevfile(new DefaultFactoryUrl().withDevfileFileLocation(myLocation), s -> myLocation + ".list", emptyMap()).get();
assertNotNull(factory);
assertNull(factory.getSource());
assertTrue(factory instanceof FactoryDevfileV2Dto);
assertEquals(((FactoryDevfileV2Dto) factory).getDevfile(), devfileAsMap);
}
use of org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto in project devspaces-images by redhat-developer.
the class URLFactoryBuilderTest method testDevfileV2WithFilename.
@Test
public void testDevfileV2WithFilename() throws ApiException, DevfileException {
String myLocation = "http://foo-location/";
Map<String, Object> devfileAsMap = Map.of("hello", "there", "how", "are", "you", "?");
JsonNode devfile = new ObjectNode(JsonNodeFactory.instance);
when(devfileParser.parseYamlRaw(anyString())).thenReturn(devfile);
when(devfileParser.convertYamlToMap(devfile)).thenReturn(devfileAsMap);
when(devfileVersionDetector.devfileMajorVersion(devfile)).thenReturn(2);
RemoteFactoryUrl githubLikeRemoteUrl = new RemoteFactoryUrl() {
@Override
public String getProviderName() {
return null;
}
@Override
public List<DevfileLocation> devfileFileLocations() {
return Collections.singletonList(new DevfileLocation() {
@Override
public Optional<String> filename() {
return Optional.of("devfile.yaml");
}
@Override
public String location() {
return myLocation;
}
});
}
@Override
public String rawFileLocation(String filename) {
return null;
}
@Override
public String getHostName() {
return null;
}
@Override
public String getBranch() {
return null;
}
@Override
public void setDevfileFilename(String devfileName) {
}
};
FactoryMetaDto factory = urlFactoryBuilder.createFactoryFromDevfile(githubLikeRemoteUrl, s -> myLocation + ".list", emptyMap()).get();
assertNotNull(factory);
assertEquals(factory.getSource(), "devfile.yaml");
assertTrue(factory instanceof FactoryDevfileV2Dto);
assertEquals(((FactoryDevfileV2Dto) factory).getDevfile(), devfileAsMap);
}
use of org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto in project devspaces-images by redhat-developer.
the class BitbucketServerAuthorizingFactoryParametersResolverTest method shouldSetScmInfoIntoDevfileV2.
@Test
public void shouldSetScmInfoIntoDevfileV2() throws Exception {
String bitbucketUrl = "http://bitbucket.2mcl.com/scm/test/repo.git?at=foobar";
FactoryDevfileV2Dto computedFactory = generateDevfileV2Factory();
when(urlFactoryBuilder.createFactoryFromDevfile(any(RemoteFactoryUrl.class), any(), anyMap())).thenReturn(Optional.of(computedFactory));
Map<String, String> params = ImmutableMap.of(URL_PARAMETER_NAME, bitbucketUrl);
// when
FactoryDevfileV2Dto factory = (FactoryDevfileV2Dto) bitbucketServerFactoryParametersResolver.createFactory(params);
// then
ScmInfo scmInfo = factory.getScmInfo();
assertNotNull(scmInfo);
assertEquals(scmInfo.getScmProviderName(), "bitbucket");
assertEquals(scmInfo.getRepositoryUrl(), "http://bitbucket.2mcl.com/scm/test/repo.git");
assertEquals(scmInfo.getBranch(), "foobar");
}
use of org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto in project devspaces-images by redhat-developer.
the class GithubFactoryParametersResolverTest method shouldSetScmInfoIntoDevfileV2.
@Test
public void shouldSetScmInfoIntoDevfileV2() throws Exception {
String githubUrl = "https://github.com/eclipse/che/tree/foobar";
FactoryDevfileV2Dto computedFactory = generateDevfileV2Factory();
when(urlFactoryBuilder.createFactoryFromDevfile(any(RemoteFactoryUrl.class), any(), anyMap())).thenReturn(Optional.of(computedFactory));
Map<String, String> params = ImmutableMap.of(URL_PARAMETER_NAME, githubUrl);
// when
FactoryDevfileV2Dto factory = (FactoryDevfileV2Dto) githubFactoryParametersResolver.createFactory(params);
// then
ScmInfo scmInfo = factory.getScmInfo();
assertNotNull(scmInfo);
assertEquals(scmInfo.getScmProviderName(), "github");
assertEquals(scmInfo.getRepositoryUrl(), "https://github.com/eclipse/che.git");
assertEquals(scmInfo.getBranch(), "foobar");
}
Aggregations