ResourceTypeCountingServiceImpl implements ResourceTypeCountingService { @Override public Collection<ResourceTypeCount> countResourceTypes(Collection<String> resources) { if (resources == null || resources.isEmpty()) { return Collections.emptySet(); } else { return aggregateCounts(countTypes(resources)); } } ResourceTypeCountingServiceImpl(ResourceStringConverter resourceStringConverter); @Override Collection<ResourceTypeCount> countResourceTypes(Collection<String> resources);  }
@Test public void testCountResourceTypes() { System.out.println("countResourceTypes"); Collection<String> resources = Arrays.asList( "video resource string1", "video resource string2", "audio resource string", "text resource string", "annotation resource string", "other resource string" ); final ResourceStringConverter converter = context.mock(ResourceStringConverter.class); context.checking(new Expectations() { { exactly(6).of(converter).getResourceInfo(with(any(String.class))); will(onConsecutiveCalls( returnValue(new ResourceInfo("href1", "fileName1", "video/mpeg", 0, 0L, ResourceType.VIDEO)), returnValue(new ResourceInfo("href2", "fileName2", "video/mpeg", 0, 0L, ResourceType.VIDEO)), returnValue(new ResourceInfo("href3", "fileName3", "audio/ogg", 0, 0L, ResourceType.AUDIO)), returnValue(new ResourceInfo("href4", "fileName4", "audio/ogg", 0, 0L, ResourceType.TEXT)), returnValue(new ResourceInfo("href5", "fileName5", "audio/ogg", 0, 0L, ResourceType.ANNOTATION)), returnValue(new ResourceInfo("href6", "fileName6", "audio/ogg", 0, 0L, ResourceType.OTHER)) )); } }); ResourceTypeCountingServiceImpl instance = new ResourceTypeCountingServiceImpl(converter); Collection<ResourceTypeCount> result = instance.countResourceTypes(resources); assertThat(result, hasItem(new ResourceTypeCount(ResourceType.VIDEO, 2))); assertThat(result, hasItem(new ResourceTypeCount(ResourceType.AUDIO, 1))); assertThat(result, hasItem(new ResourceTypeCount(ResourceType.TEXT, 1))); assertThat(result, hasItem(new ResourceTypeCount(ResourceType.ANNOTATION, 1))); assertThat(result, hasItem(new ResourceTypeCount(ResourceType.OTHER, 1))); }