List of usage examples for java.util Set equals
boolean equals(Object o);
From source file:org.openvpms.component.business.service.archetype.ArchetypeServiceListenerTestCase.java
/** * Verifies that callbacks are invoked on collection save. *///from w ww. j a va2 s .c o m @Test public void testCollectionSave() { IArchetypeService service = getArchetypeService(); Party person1 = createPerson(); Party person2 = createPerson(); Listener listener = new Listener(); service.addListener("party.customerperson", listener); service.save(Arrays.asList(person1, person2)); Set<IMObject> saved = listener.getSaved(); Set<IMObject> saving = listener.getSaving(); assertEquals(2, saved.size()); assertTrue(saving.equals(saved)); }
From source file:org.openvpms.component.business.service.archetype.ArchetypeServiceListenerTestCase.java
/** * Verifies that callbacks are invoked on save. *//* ww w. j a va 2 s . co m*/ @Test public void testSave() { IArchetypeService service = getArchetypeService(); Party person1 = createPerson(); Party person2 = createPerson(); Listener listener = new Listener(); service.addListener("party.customerperson", listener); service.save(person1); service.save(person2); Set<IMObject> saved = listener.getSaved(); Set<IMObject> saving = listener.getSaving(); assertEquals(2, saved.size()); assertTrue(saving.equals(saved)); }
From source file:org.apache.servicecomb.serviceregistry.task.MicroserviceRegisterTask.java
private boolean checkSchemaIdSet() { Microservice existMicroservice = srClient.getMicroservice(microservice.getServiceId()); if (existMicroservice == null) { LOGGER.error("Error to get microservice from service center when check schema set"); return false; }// ww w.java 2 s . co m Set<String> existSchemas = new HashSet<>(existMicroservice.getSchemas()); Set<String> localSchemas = new HashSet<>(microservice.getSchemas()); schemaIdSetMatch = existSchemas.equals(localSchemas); if (!schemaIdSetMatch) { LOGGER.warn("SchemaIds is different between local and service center. " + "serviceId=[{}] appId=[{}], name=[{}], version=[{}], env=[{}], local schemaIds={}, service center schemaIds={}", microservice.getServiceId(), microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), microservice.getEnvironment(), localSchemas, existSchemas); return true; } LOGGER.info( "SchemaIds are equals to service center. serviceId=[{}], appId=[{}], name=[{}], version=[{}], env=[{}], schemaIds={}", microservice.getServiceId(), microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), microservice.getEnvironment(), localSchemas); return true; }
From source file:org.echocat.adam.view.ViewProvider.java
@Nonnull protected Map<String, View> provideInternalFor( @Nullable Iterable<org.echocat.adam.configuration.view.View> original) { Map<String, View> result = _cache.get(original); if (result == null) { result = new LinkedHashMap<>(); if (original != null) { for (final org.echocat.adam.configuration.view.View view : original) { final String id = view.getId(); if (result.containsKey(id)) { LOG.warn("Found multiple compact definition for id '" + id + "'. The duplicate one will be ignored."); } else { result.put(id, createViewFor(view)); }/*from w w w . j a va 2 s . c o m*/ } } final View defaultView = result.get(DEFAULT_ID); if (defaultView == null) { result.put(DEFAULT_ID, createDefaultView()); } else { final Set<String> elementIds = defaultView.getElementIds(); if (!elementIds.equals(_groupProvider.getAllKnownElementIds())) { result.put(ALL_ID, createAllView()); } } if (!result.containsKey(COMPACT_ID)) { result.put(COMPACT_ID, createCompactView()); } _cache.put(original, result); } return result; }
From source file:org.openvpms.component.business.service.archetype.ArchetypeServiceListenerTestCase.java
/** * Verifies that callbacks are invoked on remove. *///from ww w . ja v a 2 s. co m @Test public void testRemove() { IArchetypeService service = getArchetypeService(); Party person1 = createPerson(); Party person2 = createPerson(); service.save(person1); service.save(person2); Listener listener = new Listener(); service.addListener("party.customerperson", listener); service.remove(person1); service.remove(person2); Set<IMObject> removed = listener.getRemoved(); Set<IMObject> removing = listener.getRemoving(); assertEquals(2, removed.size()); assertTrue(removing.equals(removed)); }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.EliminateSubplanWithInputCardinalityOneRule.java
/** * Whether the cardinality of the input free variables are one. * /*from w w w. j a va 2s . com*/ * @param opRef * the operator to be checked (including its input operators) * @param freeVars * variables to be checked for produced operators * @return true if every input variable has cardinality one; false otherwise. * @throws AlgebricksException */ private boolean isCardinalityOne(Mutable<ILogicalOperator> opRef, Set<LogicalVariable> freeVars) throws AlgebricksException { Set<LogicalVariable> varsWithCardinalityOne = new ListSet<LogicalVariable>(); Set<LogicalVariable> varsLiveAtUnnestAndJoin = new ListSet<LogicalVariable>(); isCardinalityOne(opRef, freeVars, varsWithCardinalityOne, varsLiveAtUnnestAndJoin); varsWithCardinalityOne.removeAll(varsLiveAtUnnestAndJoin); return varsWithCardinalityOne.equals(freeVars); }
From source file:org.openvpms.component.business.service.archetype.ArchetypeServiceListenerTestCase.java
/** * Verifies that callbacks are invoked on transaction commit. *///from ww w .j a v a 2 s.c om @Test public void testTransactionSave() { final IArchetypeService service = getArchetypeService(); final Party person1 = createPerson(); final Party person2 = createPerson(); final Listener listener = new Listener(); service.addListener("party.customerperson", listener); template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus status) { listener.setInTransaction(true); service.save(person1); assertTrue(listener.getSaving().contains(person1)); assertFalse(listener.getSaved().contains(person1)); service.save(person2); assertTrue(listener.getSaving().contains(person2)); assertFalse(listener.getSaved().contains(person2)); listener.setInTransaction(false); return null; } }); Set<IMObject> saved = listener.getSaved(); Set<IMObject> saving = listener.getSaving(); assertEquals(2, saved.size()); assertTrue(saving.equals(saved)); }
From source file:com.centeractive.ws.server.matcher.SoapOperationMatcher.java
/** * Last matching mechanism ->//from ww w . java2 s .c om * When a non ws-compliant document-literal service specifies wsdl:part using the type instead of the element tag * Resources: * http://stackoverflow.com/questions/1172118/what-is-the-difference-between-type-and-element-in-wsdl * http://www.xfront.com/ElementVersusType.html * http://www.xfront.com/GlobalVersusLocal.html !!! * * @param rootNodes root nodes of the request * @return operation matched */ private BindingOperation getOperationByInputTypes(final Set<Node> rootNodes) { AggregatingVisitor<BindingOperation> visitor = new AggregatingVisitor<BindingOperation>() { @Override public void visit(BindingOperation operation) { Collection<Part> expectedParts = operation.getOperation().getInput().getMessage().getParts() .values(); Set<QName> expectedTypes = new HashSet<QName>(); for (Part part : expectedParts) { expectedTypes.add(part.getElementName()); } Set<QName> receivedTypes = XmlUtils.getNodeTypes(rootNodes); if (expectedTypes.equals(receivedTypes)) { addResult(operation); } else if (expectedParts.isEmpty() && receivedTypes.size() == 1) { // check the case when pseudo input name was sent when no input was expected and got one element QName receivedType = receivedTypes.toArray(new QName[receivedTypes.size()])[0]; String namespaceUri = operation.getOperation().getInput().getMessage().getQName() .getNamespaceURI(); String name = operation.getOperation().getName(); QName pseudoInputName = new QName(namespaceUri, name); if (pseudoInputName.equals(receivedType)) { addResult(operation); } } } }; visitOperation(visitor); return visitor.getUniqueResult(); }
From source file:com.google.android.apps.dashclock.ExtensionManager.java
/** * Replaces the set of active extensions with the given list. *///from w w w. ja v a 2 s . c o m public void setActiveExtensions(Set<ComponentName> extensions) { // Join external and internal extensions Set<ComponentName> allExtensions = new HashSet<>(getInternalActiveExtensionNames()); for (ComponentName cn : extensions) { if (!allExtensions.contains(cn)) { allExtensions.add(cn); } } Map<ComponentName, ExtensionListing> infos = new HashMap<>(); for (ExtensionListing info : getAvailableExtensions()) { infos.put(info.componentName(), info); } Set<ComponentName> activeExtensionNames = getActiveExtensionNames(); if (activeExtensionNames.equals(allExtensions)) { LOGD(TAG, "No change to list of active extensions."); return; } // Clear cached data for any no-longer-active extensions. for (ComponentName cn : activeExtensionNames) { if (!allExtensions.contains(cn)) { destroyExtensionData(cn); } } // Set the new list of active extensions, loading cached data if necessary. List<ExtensionWithData> newActiveExtensions = new ArrayList<>(); for (ComponentName cn : allExtensions) { if (mExtensionInfoMap.containsKey(cn)) { newActiveExtensions.add(mExtensionInfoMap.get(cn)); } else { ExtensionWithData ewd = new ExtensionWithData(); ewd.listing = infos.get(cn); if (ewd.listing == null) { ewd.listing = new ExtensionListing(); ewd.listing.componentName(cn); } ewd.latestData = deserializeExtensionData(ewd.listing.componentName()); newActiveExtensions.add(ewd); } } mExtensionInfoMap.clear(); for (ExtensionWithData ewd : newActiveExtensions) { mExtensionInfoMap.put(ewd.listing.componentName(), ewd); } synchronized (mActiveExtensions) { mActiveExtensions.clear(); mActiveExtensions.addAll(newActiveExtensions); } LOGD(TAG, "List of active extensions has changed."); notifyOnChangeListeners(null); }
From source file:org.openvpms.component.business.service.archetype.ArchetypeServiceListenerTestCase.java
/** * Verifies that callbacks are invoked on transaction commit. *///from w w w . java2 s . c o m @Test public void testTransactionRemove() { final IArchetypeService service = getArchetypeService(); final Party person1 = createPerson(); final Party person2 = createPerson(); service.save(person1); service.save(person2); final Listener listener = new Listener(); service.addListener("party.customerperson", listener); template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus status) { listener.setInTransaction(true); service.remove(person1); assertTrue(listener.getRemoving().contains(person1)); assertFalse(listener.getRemoved().contains(person1)); service.remove(person2); assertTrue(listener.getRemoving().contains(person2)); assertFalse(listener.getRemoved().contains(person2)); listener.setInTransaction(false); return null; } }); Set<IMObject> removed = listener.getRemoved(); Set<IMObject> removing = listener.getRemoving(); assertEquals(2, removed.size()); assertTrue(removing.equals(removed)); }