use of alien4cloud.model.git.CsarGitCheckoutLocation in project alien4cloud by alien4cloud.
the class CsarGitServiceTest method importOneBranchFromGit.
@Test
public void importOneBranchFromGit() {
CsarGitCheckoutLocation alien12Location = new CsarGitCheckoutLocation();
alien12Location.setBranchId("1.2.0");
List<CsarGitCheckoutLocation> importLocations = new LinkedList<>();
importLocations.add(alien12Location);
String repoId = csarGitRepositoryService.create("https://github.com/alien4cloud/tosca-normative-types.git", "", "", importLocations, false);
List<ParsingResult<Csar>> result = csarGitService.importFromGitRepository(repoId);
Assert.assertEquals(1, result.size());
Assert.assertEquals("tosca-normative-types", result.get(0).getResult().getName());
}
use of alien4cloud.model.git.CsarGitCheckoutLocation in project alien4cloud by alien4cloud.
the class CsarGitCRUDStepDefinition method i_can_find_a_GIT_repository_with_url_usr_pwd_stored_and_locations.
@Then("^I can find a GIT repository with url \"(.*?)\" usr \"(.*?)\" pwd \"(.*?)\" stored \"(.*?)\" and locations$")
public void i_can_find_a_GIT_repository_with_url_usr_pwd_stored_and_locations(String url, String usr, String pwd, boolean stored, List<CsarGitCheckoutLocation> locations) throws Throwable {
CsarGitRepository csarGitRepository = getCsarGitRepository(url);
Assert.assertNotNull(csarGitRepository);
// a comparator to sort CsarGitCheckoutLocation lists
Comparator<CsarGitCheckoutLocation> comparator = new Comparator<CsarGitCheckoutLocation>() {
@Override
public int compare(CsarGitCheckoutLocation o1, CsarGitCheckoutLocation o2) {
int bCompare = o1.getBranchId().compareTo(o2.getBranchId());
if (bCompare != 0) {
return bCompare;
} else {
return o1.getSubPath().compareTo(o2.getSubPath());
}
}
};
Assert.assertEquals(usr, csarGitRepository.getUsername());
Assert.assertEquals(pwd, csarGitRepository.getPassword());
Assert.assertEquals(stored, csarGitRepository.isStoredLocally());
Assert.assertEquals(locations.size(), csarGitRepository.getImportLocations().size());
Collections.sort(csarGitRepository.getImportLocations(), comparator);
// locations is unmodifiable
List<CsarGitCheckoutLocation> expectedlocations = new ArrayList<CsarGitCheckoutLocation>(locations);
Collections.sort(expectedlocations, comparator);
for (int i = 0; i < expectedlocations.size(); i++) {
CsarGitCheckoutLocation expected = expectedlocations.get(i);
CsarGitCheckoutLocation actual = csarGitRepository.getImportLocations().get(i);
Assert.assertEquals(actual.getBranchId(), expected.getBranchId());
Assert.assertEquals(actual.getSubPath(), expected.getSubPath());
}
}
Aggregations