Package com.tuenti.supernanny.util

Examples of com.tuenti.supernanny.util.Version


        throw new ResolutionException(e);
      }
    }
    List<Artifact> artifacts = new ArrayList<Artifact>();
    // return artifact with wildcard version so it matches everything
    artifacts.add(new Artifact(req.getName(), new Version("*"), this, reqs));
    return artifacts;
  }
View Full Code Here


      // export deps
      Collection<Export> exports = util.parseExportsFile(exportFile);

      // if version is not implied by next version format, request
      // input, otherwise calculate it
      Version version = null;
      if (p.next == null || p.next.equals("")) {
        version = new Version(
            util.readInput("No next version specified!\nPlease input the version for this export: "));
      } else {
        Map<Version, List<Export>> last_versions = new HashMap<Version, List<Export>>();
        // determine the last version of all deps
        for (Export d : exports) {
          Version last_version = d.getRepository().getLatestVersion(d.getName());
          if (!last_versions.containsKey(last_version)) {
            last_versions.put(last_version, new ArrayList<Export>());
          }
          last_versions.get(last_version).add(d);
        }
View Full Code Here

  private Version[] getAvailableVersions(String name) throws SuperNannyError, IOException {
    String[] tags = getStrategy().getTags(uri, name);
    Version[] vs = new Version[tags.length];
    int prefixLength = (name + Util.ARCHIVE_VERSION_DELIMITER).length();
    for (int i = 0; i < tags.length; i++) {
      vs[i] = new Version(tags[i].substring(prefixLength));
    }
    return vs;
  }
View Full Code Here

        file = readField("File:");
        md5 = readField("MD5:");
        readField("Deps:");
        deps = readDeps();
        List<Requirement> reqs = depParser.parseDeps(deps);
        artifacts.add(new ArchiveArtifact(name, new Version(version), file, md5, null, reqs));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return artifacts;
View Full Code Here

  public Requirement(String name, ReqType type, String version, RepositoryType repoType,
      String repo) {
    super();
    this.name = name;
    this.version = new Version(version);
    this.type = type;
    this.repoType = repoType;
    this.repo = repo;

    // get a version for wildcard comparisons
    if (version.contains("*")) {
      switch (type) {
      case SW:
      case GE:
      case GT:
        this.versionWithoutWildcards = new Version(version.replace("*", ""));
        break;
      default:
        throw new SuperNannyError("Don't use wildcards with types other than SW,GT,GE in "
            + this);
      }
View Full Code Here

    Assert.assertEquals(4, artifacts.size());
   
    ArchiveArtifact a = artifacts.get(0);
    Assert.assertEquals("libphonenumber", a.getName());
    Assert.assertEquals(new Version("1.2.0"), a.getVersion());
    Assert.assertEquals("libphonenumber-1.2.0.tar.bz2", a.getFilename());

    List<Requirement> expectedRequirements = new LinkedList<Requirement>();
    expectedRequirements.add(new Requirement("tuenti-common", ReqType.LT, "7.8", RepositoryType.TARBZ2, "http://artifacts.tuenti.int/"));
    expectedRequirements.add(new Requirement("tfw-lib", ReqType.GT, "1.*", RepositoryType.TARBZ2, "http://artifacts.tuenti.int/"));
    Assert.assertEquals(expectedRequirements, a.getRequirements());

    a = artifacts.get(1);
    Assert.assertEquals("supervisor-common", a.getName());
    Assert.assertEquals(new Version("0.33"), a.getVersion());
    Assert.assertEquals("supervisor/supervisor-common-0.33.tar.bz2", a.getFilename());
    Assert.assertEquals(new LinkedList<Requirement>(), a.getRequirements());

    a = artifacts.get(2);
    Assert.assertEquals("fefw-fbi", a.getName());
    Assert.assertEquals(new Version("2.1"), a.getVersion());
    Assert.assertEquals("fefw-fbi-2.1.tar.bz2", a.getFilename());

    expectedRequirements = new LinkedList<Requirement>();
    expectedRequirements.add(new Requirement("tuenti-build", ReqType.LE, "16.8", RepositoryType.TARBZ2, "http://artifacts.tuenti.int/"));
    expectedRequirements.add(new Requirement("befw", ReqType.GE, "4.*", RepositoryType.TARBZ2, "http://artifacts.tuenti.int/"));
    expectedRequirements.add(new Requirement("otro", ReqType.SW, "5.*", RepositoryType.TARBZ2, "http://artifacts.tuenti.int/"));
    //expect the default GE
    expectedRequirements.add(new Requirement("squeeze", ReqType.GE, "6.*", RepositoryType.TARBZ2, "http://artifacts.tuenti.int/"));
    Assert.assertEquals(expectedRequirements, a.getRequirements());

    a = artifacts.get(3);
    Assert.assertEquals("supervisor-common", a.getName());
    Assert.assertEquals(new Version("1.0.1"), a.getVersion());
    Assert.assertEquals("supervisor-common-1.0.1.tar.bz2", a.getFilename());
    Assert.assertEquals(new LinkedList<Requirement>(), a.getRequirements());
  }
View Full Code Here

  public class ArtifactData {
    public String name;
    public Version version;
    public ArtifactData(String name, String version) {
      this.name = name;
      this.version = new Version(version);
    }
View Full Code Here

public class MatchTest {
  @Test
  public void testPrefixMatches() {
    Requirement r = new Requirement("test", ReqType.SW, "5.9", RepositoryType.GIT, "");
    Assert.assertFalse(r.matches(new Version("5.8.0")));
    Assert.assertFalse(r.matches(new Version("5.10.0")));
    Assert.assertTrue(r.matches(new Version("5.9")));
    Assert.assertTrue(r.matches(new Version("5.9.0")));
    Assert.assertTrue(r.matches(new Version("5.9.1")));
    r = new Requirement("test", ReqType.SW, "5.*", RepositoryType.GIT, "");
    Assert.assertTrue(r.matches(new Version("5.9.1")));
    Assert.assertTrue(r.matches(new Version("5.10.1")));
    Assert.assertTrue(r.matches(new Version("5")));
    Assert.assertFalse(r.matches(new Version("4.6.5")));
    Assert.assertFalse(r.matches(new Version("50.4.5")));
    r = new Requirement("test", ReqType.SW, "*", RepositoryType.GIT, "");
    Assert.assertTrue(r.matches(new Version("5.0.0")));
    Assert.assertTrue(r.matches(new Version("1")));
  }
View Full Code Here

  }

  @Test
  public void testEQMatches() {
    Requirement r = new Requirement("test", ReqType.EQ, "5.9", RepositoryType.GIT, "");
    Assert.assertFalse(r.matches(new Version("5.8.0")));
    Assert.assertFalse(r.matches(new Version("5.10.0")));
    Assert.assertTrue(r.matches(new Version("5.9")));
    Assert.assertFalse(r.matches(new Version("5.9.0")));
    Assert.assertFalse(r.matches(new Version("5.9.1")));
    try {
      r = new Requirement("test", ReqType.EQ, "5.*", RepositoryType.GIT, "");
      Assert.fail("Should have thrown an exception");
    } catch (SuperNannyError e) {

View Full Code Here

  }

  @Test
  public void testGEMatches() {
    Requirement r = new Requirement("test", ReqType.GE, "5.9", RepositoryType.GIT, "");
    Assert.assertFalse(r.matches(new Version("5.8.0")));
    Assert.assertTrue(r.matches(new Version("5.10.0")));
    Assert.assertTrue(r.matches(new Version("5.9")));
    Assert.assertTrue(r.matches(new Version("5.9.0")));
    Assert.assertFalse(r.matches(new Version("4.10.1")));
    r = new Requirement("test", ReqType.GE, "5.*", RepositoryType.GIT, "");
    Assert.assertTrue(r.matches(new Version("5.9.1")));
    Assert.assertTrue(r.matches(new Version("5.10.1")));
    Assert.assertTrue(r.matches(new Version("5")));
    Assert.assertFalse(r.matches(new Version("4.6.5")));
    Assert.assertTrue(r.matches(new Version("50.4.5")));
  }
View Full Code Here

TOP

Related Classes of com.tuenti.supernanny.util.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.