use of alien4cloud.model.git.CsarGitRepository in project alien4cloud by alien4cloud.
the class CsarGitCRUDStepDefinition method getCsarGitRepository.
private CsarGitRepository getCsarGitRepository(String url) throws Throwable {
RestResponse<GetMultipleDataResult> response = JsonUtil.read(Context.getInstance().getRestResponse(), GetMultipleDataResult.class);
assertNull(response.getError());
assertNotNull(response.getData());
for (Object object : response.getData().getData()) {
CsarGitRepository csarGitRepository = JsonUtil.readObject(JsonUtil.toString(object), CsarGitRepository.class);
if (csarGitRepository.getRepositoryUrl().equals(url)) {
return csarGitRepository;
}
}
return null;
}
use of alien4cloud.model.git.CsarGitRepository 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