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.apache.solr.sentry.SentryIndexAuthorizationSingletonTest.java

/**
 * Test getting the roles from user name
 *///from w ww.  j  av  a2  s.  co m
@Test
public void testGetRoles() throws Exception {
    Collection<String> emptyCollection = ImmutableSet.<String>of();

    // null user
    try {
        sentryInstance.getRoles(null);
        Assert.fail("Excepted SentryGroupNotFoundException");
    } catch (SentryGroupNotFoundException e) {
    }

    // no group
    try {
        sentryInstance.getRoles("withoutGroupUser");
        Assert.fail("Excepted SentryGroupNotFoundException");
    } catch (SentryGroupNotFoundException e) {
    }

    // no role
    Collection<String> roles = sentryInstance.getRoles("undefinedRoleUser");
    assertTrue(CollectionUtils.isEqualCollection(emptyCollection, roles));

    // single member
    Collection<String> singleRole = ImmutableSet.<String>of("junit_role");
    roles = sentryInstance.getRoles("junit");
    assertTrue(CollectionUtils.isEqualCollection(singleRole, roles));

    // multiple members
    Collection<String> multipleRoles = ImmutableSet.<String>of("junit_role", "queryOnlyAdmin_role",
            "updateOnlyAdmin_role");
    roles = sentryInstance.getRoles("multiGroupUser");
    assertTrue(CollectionUtils.isEqualCollection(multipleRoles, roles));
}

From source file:org.apache.sysml.hops.codegen.cplan.CNodeMultiAgg.java

@Override
public boolean equals(Object o) {
    if (!(o instanceof CNodeMultiAgg))
        return false;
    CNodeMultiAgg that = (CNodeMultiAgg) o;
    return super.equals(o) && CollectionUtils.isEqualCollection(_aggOps, that._aggOps)
            && equalInputReferences(_outputs, that._outputs, _inputs, that._inputs);
}

From source file:org.codice.alliance.catalog.plugin.security.audit.SecurityAuditPlugin.java

private boolean hasAttributeValueChanged(Attribute oldAttribute, Attribute newAttribute) {
    if (oldAttribute == null && (newAttribute != null)) {
        //The attribute was added and is not null
        return true;
    } else if (oldAttribute == null || CollectionUtils.isEmpty(oldAttribute.getValues())) {
        //The old attribute is null
        return false;
    } else if (newAttribute == null || CollectionUtils.isEmpty(newAttribute.getValues())) {
        //The attribute has been removed
        return true;
    }//from   w  w w  .  ja v  a  2s. com
    //The attribute exists in both metacards, check their equality
    return !CollectionUtils.isEqualCollection(oldAttribute.getValues(), newAttribute.getValues());
}

From source file:org.codice.ddf.catalog.plugin.security.audit.SecurityAuditPlugin.java

private boolean hasAttributeValueChanged(Attribute oldAttribute, Attribute newAttribute) {
    if (oldAttribute == null && (newAttribute != null)) {
        // The attribute was added and is not null
        return true;
    } else if (oldAttribute == null || CollectionUtils.isEmpty(oldAttribute.getValues())) {
        // The old attribute is null
        return false;
    } else if (newAttribute == null || CollectionUtils.isEmpty(newAttribute.getValues())) {
        // The attribute has been removed
        return true;
    }//from   ww  w  .j a  va  2  s. com
    // The attribute exists in both metacards, check their equality
    return !CollectionUtils.isEqualCollection(oldAttribute.getValues(), newAttribute.getValues());
}

From source file:org.datacleaner.descriptors.CompositeDescriptorProviderTest.java

@Test
public void testGetComponentDescritptors() {
    Collection<? extends ComponentDescriptor<?>> descritptors = dp.getComponentDescriptors();
    CollectionUtils.isEqualCollection(Arrays.asList(ad1, ad2), descritptors);
}

From source file:org.dataconservancy.packaging.tool.impl.DomainProfileRdfTransformServiceTest.java

@Test
public void roundTrip() throws RDFTransformException {
    DomainProfile returnedProfile = service.transformToProfile(service.transformToRdf(profile));

    assertEquals(profile, returnedProfile);

    //Since profile equals ignores node type check those here
    CollectionUtils.isEqualCollection(profile.getNodeTypes(), returnedProfile.getNodeTypes());

}

From source file:org.dataconservancy.packaging.tool.impl.DomainProfileStoreJenaImplTest.java

/**
 * Tests that the list of primary profiles is correctly returned.
 *///from w ww .j a v a2  s. c  o  m
@Test
public void testGetPrimaryProfiles() {
    assertTrue(CollectionUtils.isEqualCollection(primaryProfiles, underTest.getPrimaryDomainProfiles()));
}

From source file:org.dataconservancy.packaging.tool.impl.DomainProfileStoreJenaImplTest.java

/**
 * Tests that the list of secondary profiles is correctly returned.
 *//*from  w ww.  j  av  a  2 s.c o  m*/
@Test
public void testGetSecondaryProfiles() {
    assertTrue(CollectionUtils.isEqualCollection(secondaryProfiles, underTest.getSecondaryDomainProfiles()));
}

From source file:org.dataconservancy.packaging.tool.model.dprofile.DomainProfile.java

/**
 * Tests equality node types are not considered for equality in the profile to eliminate recursive issues.
 * @param obj The object to compare for equality
 * @return True if equal, false otherwise
 *///from   www.  j  a  v  a  2  s.  c  om
@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (!super.equals(obj))
        return false;
    if (!(obj instanceof DomainProfile))
        return false;
    DomainProfile other = (DomainProfile) obj;

    if (!other.canEqual(this))
        return false;

    if (domain_id == null) {
        if (other.domain_id != null)
            return false;
    } else if (!domain_id.equals(other.domain_id))
        return false;
    if (id == null) {
        if (other.id != null)
            return false;
    } else if (!id.equals(other.id))
        return false;
    if (node_transforms == null) {
        if (other.node_transforms != null)
            return false;
    } else if (other.node_transforms == null
            || !CollectionUtils.isEqualCollection(node_transforms, other.node_transforms))
        return false;
    if (prop_categories == null) {
        if (other.prop_categories != null)
            return false;
    } else if (other.prop_categories == null
            || !CollectionUtils.isEqualCollection(prop_categories, other.prop_categories))
        return false;
    if (prop_types == null) {
        if (other.prop_types != null)
            return false;
    } else if (other.prop_types == null || !CollectionUtils.isEqualCollection(prop_types, other.prop_types))
        return false;
    return true;
}

From source file:org.dataconservancy.packaging.tool.model.dprofile.NodeTransform.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (!super.equals(obj))
        return false;
    if (!(obj instanceof NodeTransform))
        return false;
    NodeTransform other = (NodeTransform) obj;

    if (!other.canEqual(this))
        return false;

    if (insert_parent_node_type == null) {
        if (other.insert_parent_node_type != null)
            return false;
    } else if (!insert_parent_node_type.equals(other.insert_parent_node_type))
        return false;
    if (move_children_to_parent != other.move_children_to_parent)
        return false;
    if (remove_empty_result != other.remove_empty_result)
        return false;
    if (result_node_type == null) {
        if (other.result_node_type != null)
            return false;
    } else if (!result_node_type.equals(other.result_node_type))
        return false;
    if (result_child_transforms == null) {
        if (other.result_child_transforms != null)
            return false;
    } else if (other.result_child_transforms == null
            || !CollectionUtils.isEqualCollection(result_child_transforms, other.result_child_transforms))
        return false;
    if (source_child_constraints == null) {
        if (other.source_child_constraints != null)
            return false;
    } else if (other.source_child_constraints == null
            || !CollectionUtils.isEqualCollection(source_child_constraints, other.source_child_constraints))
        return false;
    if (source_parent_constraint == null) {
        if (other.source_parent_constraint != null)
            return false;
    } else if (!source_parent_constraint.equals(other.source_parent_constraint))
        return false;
    if (source_type == null) {
        if (other.source_type != null)
            return false;
    } else if (!source_type.equals(other.source_type))
        return false;
    return true;/*w  w  w .j  a  v  a  2s . co m*/
}