Search in sources :

Example 6 with CsarGitCheckoutLocation

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());
}
Also used : ParsingResult(alien4cloud.tosca.parser.ParsingResult) CsarGitCheckoutLocation(alien4cloud.model.git.CsarGitCheckoutLocation) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 7 with CsarGitCheckoutLocation

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());
    }
}
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

CsarGitCheckoutLocation (alien4cloud.model.git.CsarGitCheckoutLocation)7 ParsingResult (alien4cloud.tosca.parser.ParsingResult)5 LinkedList (java.util.LinkedList)4 Test (org.junit.Test)4 CsarGitRepository (alien4cloud.model.git.CsarGitRepository)3 Then (cucumber.api.java.en.Then)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 Csar (org.alien4cloud.tosca.model.Csar)1