Example usage for org.apache.commons.collections CollectionUtils isEqualCollection

List of usage examples for org.apache.commons.collections CollectionUtils isEqualCollection

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils isEqualCollection.

Prototype

public static boolean isEqualCollection(final Collection a, final Collection b) 

Source Link

Document

Returns true iff the given Collection s contain exactly the same elements with exactly the same cardinalities.

Usage

From source file:org.vaadin.data.tx.ContainerTestUtils.java

public static void compareContainers(Container.Indexed expected, Container.Indexed actual) {
    Collection<?> expectedPropertyIds = expected.getContainerPropertyIds();
    Collection<?> actualPropertyIds = actual.getContainerPropertyIds();
    assertTrue("Properties IDs ", CollectionUtils.isEqualCollection(expectedPropertyIds, actualPropertyIds));
    for (Object expectedPropertyId : expectedPropertyIds) {
        assertEquals("Property Class", expected.getType(expectedPropertyId),
                actual.getType(expectedPropertyId));
    }//from  ww  w.  j a  va  2s  .c o  m
    assertEquals("Size", expected.size(), actual.size());
    for (int i = 0; i < expected.size(); i++) {
        Object expectedId = expected.getIdByIndex(i);
        Object actualId = actual.getIdByIndex(i);
        assertEquals("ItemId at index " + i, expectedId, actualId);
        Item expectedItem = expected.getItem(expectedId);
        Item actualItem = actual.getItem(expectedId);
        assertTrue("Property set", CollectionUtils.isEqualCollection(expectedItem.getItemPropertyIds(),
                actualItem.getItemPropertyIds()));
        for (Object propertyId : expectedPropertyIds) {
            assertEquals("Item:" + expectedId + "; property:" + propertyId,
                    expectedItem.getItemProperty(propertyId).getValue(),
                    actualItem.getItemProperty(propertyId).getValue());
        }
    }

}

From source file:org.wso2.carbon.identity.oidc.dcr.factory.OIDCRegistrationRequestFactoryTest.java

@Test(dataProvider = "OIDCRequestBuilderCreationData")
public void testCreate(String request, String sectorIdUrl, String subjectType, String tokenSignAlg,
        String tokenEncrAlg, String tokenEncrEnc, String userInfoRespSignAlg, String userInfoRespEncrAlg,
        String userInfoRespEnceEnc, String reqObjSignAlg, String reqObjEncrAlg, String reqObjEncrEnc,
        String tokenEPAuthSignAlg, String defaultMaxAge, String requireAuthTime, String defaultAcrValues,
        String initLoginUrl, List<String> requestUris) throws Exception {
    HttpServletRequest mockRequest = mock(HttpServletRequest.class);
    HttpServletResponse mockResponse = mock(HttpServletResponse.class);
    when(mockRequest.getReader()).thenReturn(new BufferedReader(new StringReader(request)));
    when(mockRequest.getHeaderNames()).thenReturn(Collections.<String>emptyEnumeration());
    when(mockRequest.getAttributeNames()).thenReturn(Collections.<String>emptyEnumeration());

    OIDCRegistrationRequest.OIDCRegistrationRequestBuilder requestBuilder = testedRegistrationRequestFactory
            .create(mockRequest, mockResponse);
    RegistrationRequest registrationRequest = requestBuilder.build();
    RegistrationRequestProfile requestProfile = registrationRequest.getRegistrationRequestProfile();
    assertTrue(requestProfile instanceof OIDCRegistrationRequestProfile,
            "Request profile should be an instance " + "of OIDCRegistrationRequestProfile");
    OIDCRegistrationRequestProfile oidcRegRequestProfile = (OIDCRegistrationRequestProfile) requestProfile;

    assertEquals(requestBuilder.getRequest(), mockRequest, "Builder should have the provided request.");
    assertEquals(requestBuilder.getResponse(), mockResponse, "Builder should have the provided response.");
    assertEquals(oidcRegRequestProfile.getSectorIdentifierUri(), sectorIdUrl, "Invalid Sector Id URL");
    assertEquals(oidcRegRequestProfile.getSubjectType(), subjectType, "Invalid subject type");
    assertEquals(oidcRegRequestProfile.getIdTokenSignedResponseAlg(), tokenSignAlg,
            "Invalid token sign " + "algorithm");
    assertEquals(oidcRegRequestProfile.getIdTokenEncryptedResponseAlg(), tokenEncrAlg,
            "Invalid token encryption" + " alg");
    assertEquals(oidcRegRequestProfile.getIdTokenEncryptedResponseEnc(), tokenEncrEnc,
            "Invalid token encryption" + " enc");
    assertEquals(oidcRegRequestProfile.getUserinfoSignedResponseAlg(), userInfoRespSignAlg,
            "Invalid userinfo " + "response sign alg");
    assertEquals(oidcRegRequestProfile.getUserinfoencryptedResponseAlg(), userInfoRespEncrAlg,
            "Invalid userinfo " + "response encr alg");
    assertEquals(oidcRegRequestProfile.getUserinfoEncryptedResponseEnc(), userInfoRespEnceEnc,
            "Invalid userinfo " + "response encr enc");
    assertEquals(oidcRegRequestProfile.getRequestObjectSigningAlg(), reqObjSignAlg,
            "Invalid request obj sign " + "alg");
    assertEquals(oidcRegRequestProfile.getRequestObjectEncryptionAlg(), reqObjEncrAlg,
            "Invalid request obj encr" + " alg");
    assertEquals(oidcRegRequestProfile.getRequestObjectEncryptionEnc(), reqObjEncrEnc,
            "Invalid request obj encr" + " enc");
    assertEquals(oidcRegRequestProfile.getTokenEndpointAuthSigningAlg(), tokenEPAuthSignAlg,
            "Invalid token " + "endpoint auth response alg.");
    assertEquals(oidcRegRequestProfile.getDefaultMaxAge(), defaultMaxAge, "Invalid default max age");
    assertEquals(oidcRegRequestProfile.getRequireAuthTime(), requireAuthTime, "Invalid require auth time");
    assertEquals(oidcRegRequestProfile.getDefaultAcrValues(), defaultAcrValues, "Invalid default acr values");
    assertEquals(oidcRegRequestProfile.getInitiateLoginUri(), initLoginUrl, "Invalid initiate login uri");
    assertTrue(CollectionUtils.isEqualCollection(oidcRegRequestProfile.getRequestUris(), requestUris),
            "Invalid " + "request URLs ");
}

From source file:org.xwiki.security.authorization.internal.AbstractSecurityRuleEntry.java

@Override
public boolean equals(Object object) {
    if (object == this) {
        return true;
    }/*from   w w  w.  j a  v  a2  s  . c  o  m*/
    if (!(object instanceof SecurityRuleEntry)) {
        return false;
    }
    SecurityRuleEntry other = (SecurityRuleEntry) object;

    return this.getReference().equals(other.getReference())
            && CollectionUtils.isEqualCollection(this.getRules(), other.getRules());
}

From source file:psidev.psi.mi.tab.model.AbstractBinaryInteraction.java

/**
 * {@inheritDoc}//www  . jav a2s .  co  m
 */
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    //TODO When two interactions are equals?

    AbstractBinaryInteraction that = (AbstractBinaryInteraction) o;

    if (detectionMethods != null ? !detectionMethods.equals(that.detectionMethods)
            : that.detectionMethods != null) {
        return false;
    }
    if (interactionTypes != null ? !interactionTypes.equals(that.interactionTypes)
            : that.interactionTypes != null) {
        return false;
    }

    // TODO update to (A == A' && B == B') || (B == A' && A == B')
    //interactorA or interactorB can be null
    if (interactorA == null) {
        if (that.interactorA != null && that.interactorB != null) {
            return false;
        } else if (that.interactorA == null) {
            //We check interactor B, This shouldn't be null (because then both interactor should be null)
            if (!interactorB.equals(that.interactorB)) {
                return false;
            }

        } else if (that.interactorB == null) {
            if (!interactorB.equals(that.interactorA)) {
                return false;
            }
        }
    } else if (interactorB == null) {
        if (that.interactorB != null && that.interactorA != null) {
            return false;
        } else if (that.interactorB == null) {
            //We check interactor A, This shouldn't be null (because then both interactor should be null)
            if (!interactorA.equals(that.interactorA)) {
                return false;
            }
        } else if ((interactorB == null && that.interactorA == null)) {
            if (!interactorA.equals(that.interactorB)) {
                return false;
            }
        }
    } else if (interactorA != null && interactorB != null) {
        boolean part1 = (interactorA.equals(that.interactorA) && interactorB.equals(that.interactorB));
        boolean part2 = (interactorB.equals(that.interactorA) && interactorA.equals(that.interactorB));

        if (!(part1 || part2)) {
            return false;
        }
    }

    if (publications != null ? !CollectionUtils.isEqualCollection(publications, that.publications)
            : that.publications != null) {
        return false;
    }

    if (confidenceValues != null ? !CollectionUtils.isEqualCollection(confidenceValues, that.confidenceValues)
            : that.confidenceValues != null) {
        return false;
    }

    if (sourceDatabases != null ? !CollectionUtils.isEqualCollection(sourceDatabases, that.sourceDatabases)
            : that.sourceDatabases != null) {
        return false;
    }

    if (interactionAcs != null ? !CollectionUtils.isEqualCollection(interactionAcs, that.interactionAcs)
            : that.interactionAcs != null) {
        return false;
    }

    if (authors != null ? !CollectionUtils.isEqualCollection(authors, that.authors) : that.authors != null) {
        return false;
    }

    if (complexExpansion != null ? !CollectionUtils.isEqualCollection(complexExpansion, that.complexExpansion)
            : that.complexExpansion != null) {
        return false;
    }

    if (interactionXrefs != null ? !CollectionUtils.isEqualCollection(interactionXrefs, that.interactionXrefs)
            : that.interactionXrefs != null) {
        return false;
    }

    if (interactionAnnotations != null
            ? !CollectionUtils.isEqualCollection(interactionAnnotations, that.interactionAnnotations)
            : that.interactionAnnotations != null) {
        return false;
    }

    if (hostOrganism != null ? !hostOrganism.equals(that.hostOrganism) : that.hostOrganism != null) {
        return false;
    }

    if (interactionParameters != null
            ? !CollectionUtils.isEqualCollection(interactionParameters, that.interactionParameters)
            : that.interactionParameters != null) {
        return false;
    }

    if (creationDate != null ? !CollectionUtils.isEqualCollection(creationDate, that.creationDate)
            : that.creationDate != null) {
        return false;
    }

    if (updateDate != null ? !CollectionUtils.isEqualCollection(updateDate, that.updateDate)
            : that.updateDate != null) {
        return false;
    }

    if (interactionChecksums != null
            ? !CollectionUtils.isEqualCollection(interactionChecksums, that.interactionChecksums)
            : that.interactionChecksums != null) {
        return false;
    }

    return negativeInteraction == that.negativeInteraction;

}

From source file:psidev.psi.mi.tab.model.Interactor.java

/**
 * {@inheritDoc}//  ww w  .j ava  2  s  .  co  m
 */
@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (o == null || getClass() != o.getClass())
        return false;

    //TODO When two interactions are equals?

    Interactor that = (Interactor) o;

    if (identifiers != null ? !CollectionUtils.isEqualCollection(identifiers, that.identifiers)
            : that.identifiers != null)
        return false;
    if (organism != null ? !organism.equals(that.organism) : that.organism != null)
        return false;
    if (alternativeIdentifiers != null
            ? !CollectionUtils.isEqualCollection(alternativeIdentifiers, that.alternativeIdentifiers)
            : that.alternativeIdentifiers != null)
        return false;
    if (aliases != null ? !CollectionUtils.isEqualCollection(aliases, that.aliases) : that.aliases != null)
        return false;
    if (biologicalRoles != null ? !CollectionUtils.isEqualCollection(biologicalRoles, that.biologicalRoles)
            : that.biologicalRoles != null)
        return false;
    if (experimentalRoles != null
            ? !CollectionUtils.isEqualCollection(experimentalRoles, that.experimentalRoles)
            : that.experimentalRoles != null)
        return false;
    if (interactorTypes != null ? !CollectionUtils.isEqualCollection(interactorTypes, that.interactorTypes)
            : that.interactorTypes != null)
        return false;
    if (xrefs != null ? !CollectionUtils.isEqualCollection(xrefs, that.xrefs) : that.xrefs != null)
        return false;
    if (annotations != null ? !CollectionUtils.isEqualCollection(annotations, that.annotations)
            : that.annotations != null)
        return false;
    if (checksums != null ? !CollectionUtils.isEqualCollection(checksums, that.checksums)
            : that.checksums != null)
        return false;
    if (features != null ? !CollectionUtils.isEqualCollection(features, that.features) : that.features != null)
        return false;
    if (stoichiometry != null ? !CollectionUtils.isEqualCollection(stoichiometry, that.stoichiometry)
            : that.stoichiometry != null)
        return false;
    if (participantIdentificationMethods != null
            ? !CollectionUtils.isEqualCollection(participantIdentificationMethods,
                    that.participantIdentificationMethods)
            : that.participantIdentificationMethods != null)
        return false;

    return true;
}

From source file:pt.ist.bennu.core.domain.groups.UnionGroup.java

public static UnionGroup getOrCreateUnionGroup(final PersistentGroup... persistentGroups) {
    for (PersistentGroup group : MyOrg.getInstance().getPersistentGroupsSet()) {
        if (group instanceof UnionGroup) {
            UnionGroup unionGroup = (UnionGroup) group;
            if (CollectionUtils.isEqualCollection(unionGroup.getPersistentGroupsSet(),
                    Arrays.asList(persistentGroups))) {
                return unionGroup;
            }// w w  w. j a  v  a  2  s .co m
        }
    }
    return UnionGroup.createUnionGroup(persistentGroups);
}

From source file:reconf.client.proxy.ConfigurationRepositoryFactory.java

public static synchronized <T> T get(Class<T> arg, Customization customization,
        Collection<? extends ConfigurationItemListener> configurationItemListeners) {
    setUpIfNeeded();//w w  w.ja va  2 s  .c o  m

    if (customization == null) {
        customization = new Customization();
    }
    if (configurationItemListeners == null) {
        configurationItemListeners = Collections.EMPTY_LIST;
    }

    String key = arg.getName() + customization;
    if (cache.containsKey(key)) {
        if (CollectionUtils.isEqualCollection(configurationItemListeners, listenerCache.get(key))) {
            LoggerHolder.getLog().info(msg.format("cached.instance", arg.getName()));
            return (T) cache.get(key);
        }

        throw new IllegalArgumentException(msg.format("error.customization", arg.getName()));
    }

    ConfigurationRepositoryElement repo = Environment.getFactory().create(arg);
    repo.setCustomization(customization);
    repo.setComponent(customization.getCustomComponent(repo.getComponent()));
    repo.setProduct(customization.getCustomProduct(repo.getProduct()));
    if (configurationItemListeners != null) {
        for (ConfigurationItemListener listener : configurationItemListeners) {
            repo.addConfigurationItemListener(listener);
        }
    }

    for (ConfigurationItemElement item : repo.getConfigurationItems()) {
        item.setProduct(repo.getProduct());
        item.setComponent(customization.getCustomComponent(item.getComponent()));
        item.setValue(customization.getCustomItem(item.getValue()));
    }

    LoggerHolder.getLog().info(msg.format("new.instance", LineSeparator.value(), repo.toString()));

    Object result = newInstance(arg, repo);
    cache.put(key, result);
    listenerCache.put(key, ((configurationItemListeners != null) ? configurationItemListeners
            : CollectionUtils.EMPTY_COLLECTION));
    return (T) result;
}

From source file:rocks.inspectit.ui.rcp.preferences.page.CmrRepositoryPreferencePage.java

/**
 * Where there changes performed by user.
 *
 * @return Where there changes performed by user.
 *//*from w w w.  ja v  a 2s . c  o m*/
private boolean isDirty() {
    return !CollectionUtils.isEqualCollection(inputList.keySet(),
            cmrRepositoryManager.getCmrRepositoryDefinitions());
}

From source file:software.coolstuff.springframework.owncloud.service.impl.AbstractOwncloudServiceTest.java

protected void checkAuthorities(String username, Collection<? extends GrantedAuthority> actual,
        String... expected) {//  w  w  w .  j a  v  a  2 s  . co  m
    assertThat(actual == null ? 0 : actual.size()).isEqualTo(expected.length);
    List<GrantedAuthority> authorities = new ArrayList<>();
    if (ArrayUtils.isNotEmpty(expected)) {
        for (String authority : expected) {
            authorities.add(new SimpleGrantedAuthority(authority));
        }
    }
    if (owncloudGrantedAuthoritiesMapper != null) {
        assertThat(CollectionUtils.isEqualCollection(actual,
                owncloudGrantedAuthoritiesMapper.mapAuthorities(username, authorities))).isTrue();
    } else if (grantedAuthoritiesMapper != null) {
        assertThat(
                CollectionUtils.isEqualCollection(actual, grantedAuthoritiesMapper.mapAuthorities(authorities)))
                        .isTrue();
    } else {
        assertThat(CollectionUtils.isEqualCollection(actual, authorities)).isTrue();
    }
}

From source file:uk.ac.ebi.intact.dataexchange.enricher.standard.PublicationEnricher.java

@Override
protected void processAuthors(Publication publicationToEnrich, Publication fetched) throws EnricherException {
    // == AUTHORS ===========================================================================================
    if (!CollectionUtils.isEqualCollection(publicationToEnrich.getAuthors(), fetched.getAuthors())) {
        Iterator<String> authorIterator = publicationToEnrich.getAuthors().iterator();
        while (authorIterator.hasNext()) {
            String auth = authorIterator.next();
            authorIterator.remove();/*ww  w .jav a 2s  . c  o  m*/
            if (getPublicationEnricherListener() != null)
                getPublicationEnricherListener().onAuthorRemoved(publicationToEnrich, auth);
        }
        for (String author : fetched.getAuthors()) {
            publicationToEnrich.getAuthors().add(author);
            if (getPublicationEnricherListener() != null)
                getPublicationEnricherListener().onAuthorAdded(publicationToEnrich, author);
        }
    }
}