Search in sources :

Example 6 with CsarGitRepository

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;
}
Also used : CsarGitRepository(alien4cloud.model.git.CsarGitRepository) GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult)

Example 7 with CsarGitRepository

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());
    }
}
Also used : ArrayList(java.util.ArrayList) CsarGitCheckoutLocation(alien4cloud.model.git.CsarGitCheckoutLocation) CsarGitRepository(alien4cloud.model.git.CsarGitRepository) Comparator(java.util.Comparator) Then(cucumber.api.java.en.Then)

Aggregations

CsarGitRepository (alien4cloud.model.git.CsarGitRepository)7 CsarGitCheckoutLocation (alien4cloud.model.git.CsarGitCheckoutLocation)3 Path (java.nio.file.Path)2 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)1 InvalidArgumentException (alien4cloud.exception.InvalidArgumentException)1 ParsingResult (alien4cloud.tosca.parser.ParsingResult)1 Given (cucumber.api.java.en.Given)1 Then (cucumber.api.java.en.Then)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1