### Question:
CategoryEntriesBuilder implements Factory<CategoryEntries> { public CategoryEntriesBuilder() { entryMap = new HashMap<>(); } CategoryEntriesBuilder();  CategoryEntriesBuilder(Map<String, ? extends Number> map); CategoryEntriesBuilder set(String categoryName, double score); CategoryEntriesBuilder set(Iterable<String> categoryNames, double score); CategoryEntriesBuilder add(String categoryName, double score); CategoryEntriesBuilder add(CategoryEntries categoryEntries); @Override CategoryEntries create(); double getTotalScore(); double getScore(String categoryName); @Override String toString(); static final Factory<CategoryEntriesBuilder> FACTORY; }### Answer:
@Test public void testCategoryEntriesBuilder() { CategoryEntriesBuilder builder = new CategoryEntriesBuilder(); builder.set("A", 10); builder.set("B", 50); builder.set("C", 20); builder.add("B", 20); CategoryEntries categoryEntries = builder.create(); assertEquals("B", categoryEntries.getMostLikelyCategory()); assertEquals(0.1, categoryEntries.getProbability("A"), DELTA); assertEquals(0.7, categoryEntries.getProbability("B"), DELTA); assertEquals(0.2, categoryEntries.getProbability("C"), DELTA); Iterator<Category> iterator = categoryEntries.iterator(); assertEquals("B", iterator.next().getName()); assertEquals("C", iterator.next().getName()); assertEquals("A", iterator.next().getName()); assertFalse(iterator.hasNext()); builder = new CategoryEntriesBuilder(); builder.set("A", 10); builder.set("B", 10); builder.set("D", 80); CategoryEntries categoryEntries2 = builder.create(); builder = new CategoryEntriesBuilder(); builder.add(categoryEntries); builder.add(categoryEntries2); CategoryEntries categoryEntries3 = builder.create(); assertEquals(0.1, categoryEntries3.getProbability("A"), DELTA); assertEquals(0.4, categoryEntries3.getProbability("B"), DELTA); assertEquals(0.1, categoryEntries3.getProbability("C"), DELTA); assertEquals(0.4, categoryEntries3.getProbability("D"), DELTA); }