List of usage examples for org.apache.commons.collections CollectionUtils isEqualCollection
public static boolean isEqualCollection(final Collection a, final Collection b)
From source file:grakn.core.graql.reasoner.reasoning.VariableRolesIT.java
@Test public void binaryRelationWithDifferentVariantsOfVariableRoles() { try (TransactionOLTP tx = variableRoleSession.transaction().write()) { //9 binary-base instances with {role, role2} = 2 roles for r2 -> 18 answers String queryString = "match " + "(role1: $a, $r2: $b) isa binary-base;" + "get;"; String equivalentQueryString = "match " + "($r1: $a, $r2: $b) isa binary-base;" + "$r1 type role1;" + "get $a, $b, $r2;"; List<ConceptMap> answers = tx.execute(Graql.parse(queryString).asGet()); List<ConceptMap> equivalentAnswers = tx.execute(Graql.parse(equivalentQueryString).asGet()); assertEquals(18, answers.size()); assertTrue(CollectionUtils.isEqualCollection(answers, equivalentAnswers)); //9 binary-base instances with {role, role1, role2} = 3 roles for r2 -> 27 answers String queryString2 = "match " + "(role: $a, $r2: $b) isa binary-base; " + "get;"; String equivalentQueryString2 = "match " + "($r1: $a, $r2: $b) isa binary-base; " + "$r1 type role;" + "get $a, $b, $r2;"; GraqlGet query2 = Graql.parse(queryString2).asGet(); List<ConceptMap> answers2 = tx.execute(query2); GraqlGet equivQuery2 = Graql.parse(equivalentQueryString2).asGet(); List<ConceptMap> equivalentAnswers2 = tx.execute(equivQuery2); assertEquals(27, answers2.size()); assertCollectionsNonTriviallyEqual(answers2, equivalentAnswers2); //role variables bound hence should return original 9 instances String queryString3 = "match " + "($r1: $a, $r2: $b) isa binary-base;" + "$r1 type role;" + "$r2 type role2;" + "get $a, $b;"; String equivalentQueryString3 = "match " + "(role1: $a, role2: $b) isa binary-base;" + "get;"; List<ConceptMap> answers3 = tx.execute(Graql.parse(queryString3).asGet()); List<ConceptMap> equivalentAnswers3 = tx.execute(Graql.parse(equivalentQueryString3).asGet()); assertEquals(9, answers3.size()); assertCollectionsNonTriviallyEqual(answers3, equivalentAnswers3); //9 relation instances with 7 possible permutations for each - 63 answers String queryString4 = "match " + "($r1: $a, $r2: $b) isa binary-base;" + "get;"; List<ConceptMap> answers4 = tx.execute(Graql.parse(queryString4).asGet()); assertEquals(63, answers4.size()); }//w w w. ja v a2 s . com }
From source file:de.hybris.platform.order.DeliveryModeServiceTest.java
/** * Tries to search for the delivery mode with code: * <ul>//from w ww .ja va2 s. c o m * <li>successful with "courier",</li> * <li>caught UnknownIdentifierException with "No_Such_DeliveryMode",</li> * <li>found all delivery modes, whose size is 3.</li> * </ul> */ @Test public void testGetDeliveryMode() { String deliveryModeCode = "courier"; DeliveryModeModel deliveryMode = deliveryModeService.getDeliveryModeForCode(deliveryModeCode); assertNotNull(deliveryMode); assertEquals(deliveryModeCode, deliveryMode.getCode()); deliveryModeCode = "No_Such_DeliveryMode"; try { deliveryMode = deliveryModeService.getDeliveryModeForCode(deliveryModeCode); fail("the delivery mode code [" + deliveryMode + "] should NOT be found."); } catch (final UnknownIdentifierException ue) //NOPMD { //expected } final String[] expectedDeliveryModes = { "collect", "courier", "dhl", "fedex", "post", "postService", "ups" }; final Collection<DeliveryModeModel> deliveryModes = deliveryModeService.getAllDeliveryModes(); assertEquals(expectedDeliveryModes.length, deliveryModes.size()); final List<String> _expectedDeliveryModes = Arrays.asList(expectedDeliveryModes); final List<String> _deliveryModes = new ArrayList<String>(); for (final DeliveryModeModel mode : deliveryModes) { _deliveryModes.add(mode.getCode()); } final boolean same = CollectionUtils.isEqualCollection(_expectedDeliveryModes, _deliveryModes); assertTrue(same); }
From source file:hudson.plugins.depgraph_view.model.graph.CycleFinderColorTest.java
@Test public void test1CycleEdges() throws IOException { createProjects();//from www.j av a2 s . c o m addDependency(project1, project2); addDependency(project2, project3); addDependency(project3, project1); j.getInstance().rebuildDependencyGraph(); DependencyGraph graph = generateGraph(project2); assertGraphContainsProjects(graph, project1, project2, project3); System.out.println(CycleFinder.getCycleEdges(graph)); System.out.println(graph.getEdges()); for (Edge e : graph.getEdges()) { assertTrue(e.getColor().equals("red")); } assertTrue(CollectionUtils.isEqualCollection(CycleFinder.getCycleEdges(graph), graph.getEdges())); }
From source file:com.vmware.photon.controller.apife.commands.steps.ImageSeedingProgressCheckStepCmdTest.java
@Test public void testGetSeededImageDatastores() throws ExternalException { taskEntity.setTransientResources(ImageSeedingProgressCheckStepCmd.IMAGE_ID_KEY_NAME, imageId); doReturn(false).when(imageBackend).isImageSeedingDone(imageId); List<String> expectedCandidates = Arrays.asList("imageDatastore1", "imageDatastore2"); doReturn(expectedCandidates).when(imageBackend).getSeededImageDatastores(imageId); ImageSeedingProgressCheckStepCmd cmd = new ImageSeedingProgressCheckStepCmd(taskCommand, stepBackend, stepEntity, imageBackend);/* w w w .j a v a2 s . c o m*/ cmd.execute(); Object result = taskEntity .getTransientResources(ImageSeedingProgressCheckStepCmd.CANDIDATE_IMAGE_STORES_KEY_NAME); assertThat(result, is(notNullValue())); List<String> candidateImageDatastores = (List<String>) result; assertThat(candidateImageDatastores.size(), is(expectedCandidates.size())); assertThat(CollectionUtils.isEqualCollection(candidateImageDatastores, expectedCandidates), is(true)); }
From source file:com.hurence.logisland.record.StandardRecord.java
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StandardRecord record = (StandardRecord) o; if (getAllFields() == null || record.getAllFields() == null || !CollectionUtils.isEqualCollection(this.getAllFields(), record.getAllFields())) return false; return getId() != null ? getId().equals(record.getId()) : record.getId() == null; }
From source file:com.shigengyu.hyperion.core.TransitionConditionSet.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/*from ww w. j a va2s.c om*/ if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } TransitionConditionSet other = (TransitionConditionSet) obj; if (conditions == null) { if (other.conditions != null) { return false; } } else if (!CollectionUtils.isEqualCollection(conditions, other.conditions)) { return false; } return true; }
From source file:be.solidx.hot.shows.ClosureRequestMapping.java
@Override public boolean equals(Object obj) { if (obj != null && obj instanceof ClosureRequestMapping) { ClosureRequestMapping closureRequestMapping = (ClosureRequestMapping) obj; return CollectionUtils.isEqualCollection(getPaths(), closureRequestMapping.getPaths()) && getRequestMethod().equals(closureRequestMapping.getRequestMethod()) && CollectionUtils.isEqualCollection(getHeaders(), closureRequestMapping.getHeaders()); }/*ww w . j av a 2s . co m*/ return false; }
From source file:com.cloudera.nav.plugin.client.HttpJsonMetadataWriterTest.java
@SuppressWarnings("unchecked") @Test/* w w w . j ava 2 s . com*/ public void testWriteBasic() throws IOException { Source source = new Source("HDFS-1", SourceType.HDFS, "Cluster", "http://ns1"); HdfsEntity entity = new HdfsEntity(); entity.setSourceId(source.getIdentity()); entity.setFileSystemPath("/user/test"); entity.setType(EntityType.DIRECTORY); entity.setTags(ImmutableList.of("foo", "bar")); HttpJsonMetadataWriter mWriter = new HttpJsonMetadataWriter(config, mockWriter, mockConn); mWriter.write(entity); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(mockWriter).append(captor.capture()); String value = captor.getValue(); ObjectMapper mapper = new ObjectMapper(); Map<String, Object> values = (Map<String, Object>) mapper.readValue(value, Map.class); assertEquals(values.get("identity"), entity.getIdentity()); assertEquals(values.get("fileSystemPath"), entity.getFileSystemPath()); assertEquals(values.get("sourceId"), source.getIdentity()); assertEquals(values.get("sourceType"), SourceType.HDFS.name()); assertEquals(values.get("type"), EntityType.DIRECTORY.name()); assertEquals(values.get("deleted"), false); assertTrue(CollectionUtils.isEqualCollection((Collection<String>) values.get("tags"), ImmutableList.of("foo", "bar"))); }
From source file:com.qrmedia.commons.lang.ClassUtilsTest.java
/** * Tests whether the given superclass limit is observed. *///www. j a va 2 s . c o m @Test public void getAllDeclaredFields_givenSuperclass() { List<Field> expectedFields = new ArrayList<Field>(); expectedFields.addAll(Arrays.asList(Child.class.getDeclaredFields())); expectedFields.addAll(Arrays.asList(Grandchild.class.getDeclaredFields())); assertTrue(CollectionUtils.isEqualCollection(expectedFields, ClassUtils.getAllDeclaredFields(Grandchild.class, Child.class))); }
From source file:com.qrmedia.commons.collections.PairUtilsTest.java
@Test public void toPairs_subclass_nullSecondObject() { String firstObject = "007"; assertTrue(CollectionUtils.isEqualCollection(Arrays.asList(new StringBooleanPair(firstObject, null)), PairUtils.toPairs(StringBooleanPair.class, Arrays.asList(firstObject), null))); }