@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 matchWithCriteria() { deploymentProperties.setCount(0); deploymentProperties.setCriteria("color=='green'"); 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()); }
@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 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 matchWithCountLessThanContainersMatchingCriteria() { deploymentProperties.setCount(1); deploymentProperties.setCriteria("group=='group2'"); Collection<Container> matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); Iterator<Container> matchedIterator = matched.iterator(); assertSame(containers.get(1), matchedIterator.next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); matchedIterator = matched.iterator(); assertSame(containers.get(2), matchedIterator.next()); matched = containerMatcher.match(moduleDescriptor, deploymentProperties, containers); assertEquals(1, matched.size()); matchedIterator = matched.iterator(); assertSame(containers.get(1), matchedIterator.next()); }