Ejemplo n.º 1
0
  @Test
  public void testEnvironmentII() {

    Tier tier = new Tier("name1", new Integer(1), new Integer(5), new Integer(1), null);
    tier.setRegion("region1");
    tier.addNetwork(new Network("uno2", VDC, REGION));

    Tier tier3 = new Tier("name3", new Integer(1), new Integer(5), new Integer(1), null);
    tier3.setRegion("region3");
    tier3.addNetwork(new Network("uno2", VDC, REGION));

    Tier tier2 = new Tier("name2", new Integer(1), new Integer(5), new Integer(1), null);
    tier2.setRegion("region2");
    tier2.addNetwork(new Network("uno", VDC, REGION));

    Set<Tier> tiers = new HashSet<Tier>();
    tiers.add(tier);

    Environment envResult = new Environment("environemntName", tiers);
    assertEquals(envResult.getTiers().size(), 1);

    envResult.addTier(tier2);
    assertEquals(envResult.getTiers().size(), 2);

    envResult.deleteTier(tier);
    assertEquals(envResult.getTiers().size(), 1);

    envResult.updateTier(tier2, tier3);

    for (Tier t : envResult.getTiers()) {
      assertEquals(t.getName(), "name3");
    }
  }
Ejemplo n.º 2
0
  @Test
  public void testCreateEnvironment() throws Exception {

    ProductRelease productRelease = new ProductRelease("product", "2.0");
    List<ProductRelease> productReleases = new ArrayList<ProductRelease>();
    productReleases.add(productRelease);

    Tier tier = new Tier();
    tier.setInitialNumberInstances(new Integer(1));
    tier.setMaximumNumberInstances(new Integer(5));
    tier.setMinimumNumberInstances(new Integer(1));
    tier.setName("tierName");
    tier.setProductReleases(productReleases);
    tier.setFlavour("3");
    tier.setFloatingip("true");
    tier.setImage("image");

    Tier tier2 =
        new Tier(
            "name",
            new Integer(1),
            new Integer(1),
            new Integer(1),
            productReleases,
            "4",
            "image2",
            "icone2");

    Set<Tier> tiers = new HashSet<Tier>();
    tiers.add(tier);
    tiers.add(tier2);

    Environment envResult = new Environment();
    envResult.setName("environemntName");
    envResult.addTier(tier2);
    envResult.addTier(tier);
    // envResult.setTiers(tiers);

    EnvironmentDto envDto = envResult.toDto();
    Environment env2 = envDto.fromDto();
    assertEquals(env2, envResult);

    assertEquals(envResult.getTiers().size(), 2);
  }
Ejemplo n.º 3
0
  @Test
  public void testIsDifferentRegions() {
    Tier tier = new Tier("name1", new Integer(1), new Integer(5), new Integer(1), null);
    tier.setRegion("region1");

    Tier tier2 = new Tier("name2", new Integer(1), new Integer(5), new Integer(1), null);
    tier.setRegion("region2");

    Set<Tier> tiers = new HashSet<Tier>();
    tiers.add(tier);
    tiers.add(tier2);

    Environment env = new Environment();

    env.setName("environmentName");
    env.addTier(tier);
    env.addTier(tier2);

    boolean result = env.isDifferentRegions();
    assertEquals(result, true);
  }