Ejemplo n.º 1
0
 private void assertStarters(List<SpringBootStarter> starters, String... expectedIds) {
   Set<String> expecteds = new HashSet<>(Arrays.asList(expectedIds));
   for (SpringBootStarter starter : starters) {
     String id = starter.getId();
     if (expecteds.remove(id)) {
       // okay
     } else {
       fail("Unexpected starter found: " + starter);
     }
   }
   if (!expecteds.isEmpty()) {
     fail("Expected starters not found: " + expecteds);
   }
 }
Ejemplo n.º 2
0
  private void assertUsageCounts(
      ISpringBootProject project, PopularityTracker popularities, String... idAndCount)
      throws Exception {
    Map<String, Integer> expect = new HashMap<>();
    for (String pair : idAndCount) {
      String[] pieces = pair.split(":");
      assertEquals(2, pieces.length);
      String id = pieces[0];
      int count = Integer.parseInt(pieces[1]);
      expect.put(id, count);
    }

    List<SpringBootStarter> knownStarters = project.getKnownStarters();
    assertFalse(knownStarters.isEmpty());
    for (SpringBootStarter starter : knownStarters) {
      String id = starter.getId();
      Integer expectedCountOrNull = expect.get(id);
      int expectedCount = expectedCountOrNull == null ? 0 : expectedCountOrNull;
      assertEquals("Usage count for '" + id + "'", expectedCount, popularities.getUsageCount(id));
      expect.remove(id);
    }

    assertTrue("Expected usage counts not found: " + expect, expect.isEmpty());
  }