List of usage examples for org.apache.commons.collections CollectionUtils isEqualCollection
public static boolean isEqualCollection(final Collection a, final Collection b)
From source file:org.nuxeo.ecm.tokenauth.TestTokenAuthenticationService.java
@Test public void testGetTokenBindings() { // Test empty token bindings assertEquals(0, tokenAuthenticationService.getTokenBindings("john").size()); // Test existing token bindings String token1 = tokenAuthenticationService.acquireToken("joe", "myFavoriteApp", "Ubuntu box 64 bits", "This is my personal Linux box", "rw"); log.debug("token1 = " + token1); String token2 = tokenAuthenticationService.acquireToken("joe", "myFavoriteApp", "Windows box 32 bits", "This is my personal Windows box", "rw"); log.debug("token2 = " + token2); String token3 = tokenAuthenticationService.acquireToken("joe", "nuxeoDrive", "Mac OSX VM", "This is my personal Mac box", "rw"); log.debug("token3 = " + token3); DocumentModelList tokenBindings = tokenAuthenticationService.getTokenBindings("joe"); assertEquals(3, tokenBindings.size()); Set<AuthenticationToken> expectedTokenBindings = new HashSet<AuthenticationToken>(); expectedTokenBindings.add(new AuthenticationToken(token1, "joe", "myFavoriteApp", "Ubuntu box 64 bits", "This is my personal Linux box", "rw")); expectedTokenBindings.add(new AuthenticationToken(token2, "joe", "myFavoriteApp", "Windows box 32 bits", "This is my personal Windows box", "rw")); expectedTokenBindings.add(new AuthenticationToken(token3, "joe", "nuxeoDrive", "Mac OSX VM", "This is my personal Mac box", "rw")); assertTrue(CollectionUtils.isEqualCollection(expectedTokenBindings, asAuthenticationTokens(tokenBindings))); for (DocumentModel tokenBinding : tokenBindings) { assertNotNull(tokenBinding.getPropertyValue("authtoken:creationDate")); }//from ww w. j a v a 2s.c om }
From source file:org.onosproject.faultmanagement.impl.AlarmManager.java
protected synchronized void updateAlarms(DeviceId deviceId, Set<Alarm> discoveredSet) { Set<Alarm> storedSet = getActiveAlarms(deviceId); log.debug("CurrentNeAlarms={}. DiscoveredAlarms={}", storedSet, discoveredSet); if (CollectionUtils.isEqualCollection(storedSet, discoveredSet)) { log.debug("No update for {}.", deviceId); return;// www.ja v a 2s . c o m } //TODO implement distinction between UPDATED and CLEARED ALARMS storedSet.stream().filter((stored) -> (!discoveredSet.contains(stored))).forEach((stored) -> { log.debug("Alarm will be Cleared as it is not on the device. Cleared alarm: {}.", stored); clear(stored.id()); }); discoveredSet.stream().filter((discovered) -> (!storedSet.contains(discovered))).forEach((discovered) -> { log.info("New alarm raised {}", discovered); AlarmId id = generateAlarmId(); store.setAlarm(new DefaultAlarm.Builder(discovered).withId(id).build()); }); }
From source file:org.onosproject.faultmanagement.impl.AlarmsManager.java
synchronized void updateAlarms(Set<Alarm> discoveredSet, DeviceId deviceId) { Set<Alarm> storedSet = getActiveAlarms(deviceId); log.trace("currentNeAlarms={}. discoveredAlarms={}", storedSet, discoveredSet); if (CollectionUtils.isEqualCollection(storedSet, discoveredSet)) { log.debug("Alarm lists are equivalent so no update for {}.", deviceId); return;/* w w w.j av a 2 s . c om*/ } storedSet.stream().filter((stored) -> (!discoveredSet.contains(stored))).forEach((stored) -> { log.info("Alarm will be cleared as it is not on the element. Cleared alarm: {}.", stored); clear(stored.id()); }); discoveredSet.stream().filter((discovered) -> (!storedSet.contains(discovered))).forEach((discovered) -> { log.info("Alarm will be raised as it is missing. New alarm: {}.", discovered); AlarmId id = generateAlarmId(); alarms.put(id, new DefaultAlarm.Builder(discovered).withId(id).build()); }); }
From source file:org.onosproject.net.pi.runtime.PiActionGroupTest.java
/** * Checks the methods of PiActionGroup./*from w w w.ja va 2 s . com*/ */ @Test public void testMethods() { Collection<PiActionGroupMember> piActionGroupMembers = Lists.newArrayList(); piActionGroupMembers.add(piActionGroupMember); assertThat(piActionGroup1, is(notNullValue())); assertThat(piActionGroup1.id(), is(piActionGroupId)); assertThat("Incorrect members value", CollectionUtils.isEqualCollection(piActionGroup1.members(), piActionGroupMembers)); }
From source file:org.onosproject.net.pi.runtime.PiMatchKeyTest.java
/** * Checks the methods of PiMatchKey./*from w w w . j av a2s . c om*/ */ @Test public void testMethods() { Collection<PiFieldMatch> piFieldMatches = Lists.newArrayList(); piFieldMatches.add(piLpmFieldMatch1); piFieldMatches.add(piLpmFieldMatch2); final PiMatchKey piMatchKey = PiMatchKey.builder().addFieldMatches(piFieldMatches).build(); assertThat(piMatchKey, is(notNullValue())); assertThat("Incorrect members value", CollectionUtils.isEqualCollection(piMatchKey.fieldMatches(), piFieldMatches)); }
From source file:org.onosproject.net.pi.runtime.PiPacketOperationTest.java
/** * Checks the methods of PiPacketOperation. *///ww w . ja v a2 s .c om @Test public void testMethods() { final PiPacketOperation piPacketOperation = PiPacketOperation.builder().forDevice(deviceId) .withData(ImmutableByteSequence.ofOnes(512)).withType(PACKET_OUT) .withMetadata(PiControlMetadata.builder().withId(PiControlMetadataId.of(EGRESS_PORT)) .withValue(copyFrom((short) 10)).build()) .build(); assertThat(piPacketOperation, is(notNullValue())); assertThat(piPacketOperation.deviceId(), is(deviceId)); assertThat(piPacketOperation.type(), is(PACKET_OUT)); assertThat(piPacketOperation.data(), is(ImmutableByteSequence.ofOnes(512))); assertThat("Incorrect metadatas value", CollectionUtils.isEqualCollection(piPacketOperation.metadatas(), ImmutableList.of(PiControlMetadata.builder().withId(PiControlMetadataId.of(EGRESS_PORT)) .withValue(copyFrom((short) 10)).build()))); }
From source file:org.onosproject.net.pi.runtime.PiTableEntryTest.java
/** * Tests creation of a DefaultFlowRule using a FlowRule constructor. *//*from w ww.java 2 s. com*/ @Test public void testBuilder() { PiTableId piTableId = PiTableId.of("table10"); long cookie = 0xfff0323; int priority = 100; double timeout = 1000; PiMatchFieldId piMatchFieldId = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR); PiFieldMatch piFieldMatch = new PiExactFieldMatch(piMatchFieldId, ImmutableByteSequence.copyFrom(0x0a010101)); PiAction piAction = PiAction.builder().withId(PiActionId.of(DROP)).build(); final Map<PiMatchFieldId, PiFieldMatch> fieldMatches = Maps.newHashMap(); fieldMatches.put(piMatchFieldId, piFieldMatch); final PiTableEntry piTableEntry = PiTableEntry.builder().forTable(piTableId) .withMatchKey(PiMatchKey.builder().addFieldMatches(fieldMatches.values()).build()) .withAction(piAction).withCookie(cookie).withPriority(priority).withTimeout(timeout).build(); assertThat(piTableEntry.table(), is(piTableId)); assertThat(piTableEntry.cookie(), is(cookie)); assertThat("Priority must be set", piTableEntry.priority().isPresent()); assertThat("Timeout must be set", piTableEntry.timeout().isPresent()); assertThat(piTableEntry.priority().get(), is(priority)); assertThat(piTableEntry.timeout().get(), is(timeout)); assertThat("Incorrect match param value", CollectionUtils.isEqualCollection(piTableEntry.matchKey().fieldMatches(), fieldMatches.values())); assertThat(piTableEntry.action(), is(piAction)); }
From source file:org.openengsb.connector.userprojects.ldap.internal.ldap.DefaultModelManagerTest.java
@Test @Ignore//from w w w . j a va 2s.com public void testFindAssignments() throws InterruptedException { Assignment assignment = createTestAssignment(); List<Assignment> expected = Arrays.asList(assignment); ldapService.updateAssignments(expected); assertTrue(CollectionUtils.isEqualCollection(modelManager.findAssignments(), expected)); }
From source file:org.openengsb.connector.userprojects.ldap.internal.ldap.DefaultModelManagerTest.java
@Test @Ignore/*from ww w .j a va2 s. c o m*/ public void testFindProjects() throws InterruptedException { Project project = createTestProject(); List<Project> expected = Arrays.asList(project); ldapService.updateProjects(expected); assertTrue(CollectionUtils.isEqualCollection(modelManager.findProjects(), expected)); }
From source file:org.openengsb.connector.userprojects.ldap.internal.ldap.DefaultModelManagerTest.java
@Test @Ignore/*w w w .j a v a 2 s . c o m*/ public void testFindRoles() throws InterruptedException { Role role = createTestRole(); List<Role> expected = Arrays.asList(role); ldapService.updateRoles(expected); assertTrue(CollectionUtils.isEqualCollection(modelManager.findRoles(), expected)); }