Ejemplo n.º 1
0
  private static void assertSameNodesCollections(
      String objectName, Iterable<SNode> expected, Iterable<SNode> actual) {
    HashMap<SNodeId, SNode> actualIdToNodeMap = new HashMap<SNodeId, SNode>();
    for (SNode actualNode : actual) {
      actualIdToNodeMap.put(actualNode.getNodeId(), actualNode);
    }

    for (SNode expectedNode : expected) {
      SNodeId rootId = expectedNode.getNodeId();
      SNode actualNode = actualIdToNodeMap.get(rootId);
      assertNotNull("Not found expected " + objectName + " " + expectedNode, actualNode);
      assertDeepNodeEquals(expectedNode, actualNode);
      actualIdToNodeMap.remove(rootId);
    }

    assertTrue(
        "Found not expected " + objectName + " " + actualIdToNodeMap, actualIdToNodeMap.isEmpty());
  }
Ejemplo n.º 2
0
  @org.junit.Test
  public void testGenerateValuesZeroCountIngredientDependency() throws Exception {
    mappingCollector.setValueBefore("a", 2);
    mappingCollector.setValueBefore("b", 3);
    mappingCollector.setValueBefore("notConsume1", 1);
    HashMap<String, Integer> ingredients = new HashMap<>();
    ingredients.put("a", 1);
    ingredients.put("b", 1);
    ingredients.put("notConsume1", 0);
    mappingCollector.addConversion(1, "c1", ingredients);
    ingredients.remove("notConsume1");
    ingredients.put("notConsume2", 0);
    mappingCollector.addConversion(1, "c2", ingredients);

    Map<String, Integer> values = valueGenerator.generateValues();
    assertEquals(2, getValue(values, "a"));
    assertEquals(3, getValue(values, "b"));
    assertEquals(1, getValue(values, "notConsume1"));
    assertEquals(0, getValue(values, "notConsume2"));
    assertEquals(5, getValue(values, "c1"));
    assertEquals(0, getValue(values, "c2"));
  }