Пример #1
0
  public void testFromArgs() {
    Map m1 =
        MapUtil.map(
            "a", "1", "b", "2", "c", "3", "d", "4", "e", "5", "f", "6", "g", "7", "h", "8", "j",
            "9", "k", "10");
    Map exp = new HashMap();
    exp.put("a", "1");
    exp.put("b", "2");
    exp.put("c", "3");
    exp.put("d", "4");
    exp.put("e", "5");
    exp.put("f", "6");
    exp.put("g", "7");
    exp.put("h", "8");
    exp.put("j", "9");
    exp.put("k", "10");
    assertEquals(exp, m1);

    try {
      MapUtil.map(
          "a", "1", "b", "2", "c", "3", "d", "4", "e", "5", "f", "6", "g", "7", "h", "8", "j", "9",
          "k");
      fail("Odd length arg list should throw");
    } catch (IllegalArgumentException e) {
    }
  }
  public void testFindLeastFullRepository() throws Exception {
    Map repoMap =
        MapUtil.map(
            "local:one",
            new MyDF("/one", 1000),
            "local:two",
            new MyDF("/two", 3000),
            "local:three",
            new MyDF("/three", 2000));
    mgr.setRepoMap(repoMap);

    assertEquals("local:two", mgr.findLeastFullRepository());
  }
Пример #3
0
  public void testFromList1() {
    assertEquals(MapUtil.map(), MapUtil.fromList(ListUtil.list()));
    assertEquals(
        MapUtil.map("FOO", "bar", "One", "Two"),
        MapUtil.fromList(ListUtil.list("FOO", "bar", "One", "Two")));
    assertEquals(
        MapUtil.map("foo", "bar", "one", "two"),
        MapUtil.fromList(ListUtil.list(ListUtil.list("foo", "bar"), ListUtil.list("one", "two"))));

    try {
      MapUtil.fromList(ListUtil.list("FOO", "bar", "One"));
      fail("Odd length arg list should throw");
    } catch (IllegalArgumentException e) {
    }
    try {
      MapUtil.fromList(ListUtil.list(ListUtil.list("foo", "bar"), ListUtil.list("one")));
      fail("Short sublist should throw");
    } catch (IllegalArgumentException e) {
    }
  }
Пример #4
0
 public void testSubstanceState() {
   AuState aus = new AuState(mau, historyRepo);
   assertEquals(SubstanceChecker.State.Unknown, aus.getSubstanceState());
   assertFalse(aus.hasNoSubstance());
   aus.setSubstanceState(SubstanceChecker.State.Yes);
   assertEquals(1, historyRepo.getAuStateStoreCount());
   assertEquals(SubstanceChecker.State.Yes, aus.getSubstanceState());
   assertFalse(aus.hasNoSubstance());
   aus.setSubstanceState(SubstanceChecker.State.No);
   assertEquals(2, historyRepo.getAuStateStoreCount());
   assertEquals(SubstanceChecker.State.No, aus.getSubstanceState());
   assertTrue(aus.hasNoSubstance());
   assertNotEquals("2", aus.getFeatureVersion(Plugin.Feature.Substance));
   mplug.setFeatureVersionMap(MapUtil.map(Plugin.Feature.Substance, "2"));
   aus.setSubstanceState(SubstanceChecker.State.Yes);
   // changing both the substance state and feature version should store
   // only once
   assertEquals(3, historyRepo.getAuStateStoreCount());
   assertEquals(SubstanceChecker.State.Yes, aus.getSubstanceState());
   assertEquals("2", aus.getFeatureVersion(Plugin.Feature.Substance));
 }
Пример #5
0
 public void testExpandMultiKeys() {
   assertEquals(MapUtil.map(), MapUtil.expandAlternativeKeyLists(MapUtil.map()));
   assertEquals(MapUtil.map("1", "A"), MapUtil.expandAlternativeKeyLists(MapUtil.map("1", "A")));
   assertEquals(
       MapUtil.map("1", "A", "2", "A"),
       MapUtil.expandAlternativeKeyLists(MapUtil.map("1;2", "A")));
   assertEquals(
       MapUtil.map("1", "A", "2", "B", "*", "B"),
       MapUtil.expandAlternativeKeyLists(MapUtil.map("1", "A", "2;*", "B")));
 }