@Test public void matchWithCountLessThanNumberOfContainers() { deploymentProperties.setCount(2); Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(2, matched.size()); Iterator<Container> matchedIterator = matched.iterator(); assertSame(containers.get(0), matchedIterator.next()); assertSame(containers.get(1), matchedIterator.next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(2, matched.size()); matchedIterator = matched.iterator(); assertSame(containers.get(2), matchedIterator.next()); assertSame(containers.get(0), matchedIterator.next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(2, matched.size()); matchedIterator = matched.iterator(); assertSame(containers.get(1), matchedIterator.next()); assertSame(containers.get(2), matchedIterator.next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(2, matched.size()); matchedIterator = matched.iterator(); assertSame(containers.get(0), matchedIterator.next()); assertSame(containers.get(1), matchedIterator.next()); }
@Test public void matchWithCountGreaterThanToNumberOfContainers() { deploymentProperties.setCount(5); Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(3, matched.size()); }
@Test public void matchWithZeroCount() { deploymentProperties.setCount(0); Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(3, matched.size()); }
@Test public void matchWithInvalidCriteria() { deploymentProperties.setCount(0); deploymentProperties.setCriteria("color"); Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(0, matched.size()); }
@Test public void matchWithCountAndCriteria() { deploymentProperties.setCount(3); deploymentProperties.setCriteria("group=='group2'"); Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(2, matched.size()); Iterator<Container> matchedIterator = matched.iterator(); assertSame(containers.get(1), matchedIterator.next()); assertSame(containers.get(2), matchedIterator.next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(2, matched.size()); matchedIterator = matched.iterator(); assertSame(containers.get(1), matchedIterator.next()); assertSame(containers.get(2), matchedIterator.next()); }
@Test public void basicRoundRobin() { Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); assertSame(containers.get(0), matched.iterator().next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); assertSame(containers.get(1), matched.iterator().next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); assertSame(containers.get(2), matched.iterator().next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); assertSame(containers.get(0), matched.iterator().next()); }