List of usage examples for java.util Map equals
boolean equals(Object o);
From source file:org.xdi.oxauth.service.SessionIdService.java
public SessionId updateSessionIfNeeded(SessionId session, String redirectUri, String acrValuesStr) throws AcrChangedException { if (session != null && !session.getSessionAttributes().isEmpty()) { final Map<String, String> sessionAttributes = session.getSessionAttributes(); boolean isAcrChanged = acrValuesStr != null && !acrValuesStr.equals(sessionAttributes.get("acr_values")); if (isAcrChanged) { throw new AcrChangedException(); }/* w w w .j a v a2 s .c om*/ final Map<String, String> currentSessionAttributes = getCurrentSessionAttributes(sessionAttributes); if (!currentSessionAttributes.equals(sessionAttributes)) { sessionAttributes.putAll(currentSessionAttributes); // Reinit login sessionAttributes.put("auth_step", "1"); for (Iterator<Entry<String, String>> it = currentSessionAttributes.entrySet().iterator(); it .hasNext();) { Entry<String, String> currentSessionAttributesEntry = it.next(); String name = currentSessionAttributesEntry.getKey(); if (name.startsWith("auth_step_passed_")) { it.remove(); } } session.setSessionAttributes(currentSessionAttributes); boolean updateResult = updateSessionId(session, true, true); if (!updateResult) { log.debug("Failed to update session entry: '{0}'", session.getId()); } } } return session; }
From source file:org.openehr.designer.diff.ArchetypeDifferentiator.java
private void removeUnspecializedTermDefinitions(Archetype diffChild) { ArchetypeWrapper diffChildWrapper = new ArchetypeWrapper(diffChild); List<String> languages = diffChild.getTerminology().getTermDefinitions().stream() .map(CodeDefinitionSet::getLanguage).collect(Collectors.toList()); if (diffChild.getTerminology().getTermDefinitions().isEmpty()) return;//ww w . ja v a2s. co m List<String> termIds = diffChild.getTerminology().getTermDefinitions().get(0).getItems().stream() .map(ArchetypeTerm::getCode).collect(Collectors.toList()); Set<String> termsToKeep = new HashSet<>(); termLoop: for (String termId : termIds) { if (getSpecializationDepth(termId) == archetypeSpecializationDepth) { termsToKeep.add(termId); continue; } for (String language : languages) { Map<String, String> diffTerm = diffChildWrapper.getTerm(language, termId); Map<String, String> parentTerm = flatParentWrapper.getTerm(language, termId); if (diffTerm != null && !diffTerm.equals(parentTerm)) { termsToKeep.add(termId); continue termLoop; } } } for (CodeDefinitionSet codeDefinitionSet : diffChild.getTerminology().getTermDefinitions()) { for (Iterator<ArchetypeTerm> iterator = codeDefinitionSet.getItems().iterator(); iterator.hasNext();) { ArchetypeTerm at = iterator.next(); if (!termsToKeep.contains(at.getCode())) { iterator.remove(); } } } }
From source file:com.acc.test.orders.AcceleratorTestOrderData.java
protected boolean matchesOrder(final OrderModel order, final Map<String, Long> products) { final Map<String, Long> entryQuantityMap = getEntryQuantityMap(order); final Map<String, Long> productsTreeMap = new TreeMap<String, Long>(products); return entryQuantityMap.equals(productsTreeMap); }
From source file:com.linkedin.pinot.perf.PerfBenchmarkDriver.java
public void run() throws Exception { startZookeeper();/* www .j ava2 s. c o m*/ startController(); startBroker(); startServer(); configureResources(); uploadIndexSegments(); final ZKHelixAdmin helixAdmin = new ZKHelixAdmin(zkAddress); Verifier customVerifier = new Verifier() { @Override public boolean verify() { List<String> resourcesInCluster = helixAdmin.getResourcesInCluster(clusterName); LOGGER.info("Waiting for the cluster to be set up and indexes to be loaded on the servers" + new Timestamp(System.currentTimeMillis())); for (String resourceName : resourcesInCluster) { IdealState idealState = helixAdmin.getResourceIdealState(clusterName, resourceName); ExternalView externalView = helixAdmin.getResourceExternalView(clusterName, resourceName); if (idealState == null || externalView == null) { return false; } Set<String> partitionSet = idealState.getPartitionSet(); for (String partition : partitionSet) { Map<String, String> instanceStateMapIS = idealState.getInstanceStateMap(partition); Map<String, String> instanceStateMapEV = externalView.getStateMap(partition); if (instanceStateMapIS == null || instanceStateMapEV == null) { return false; } if (!instanceStateMapIS.equals(instanceStateMapEV)) { return false; } } } LOGGER.info("Cluster is ready to serve queries"); return true; } }; ClusterStateVerifier.verifyByPolling(customVerifier, 60 * 1000); postQueries(); }
From source file:org.elasticsearch.xpack.qa.sql.multinode.RestSqlMultinodeIT.java
private void assertCount(RestClient client, int count) throws IOException { Map<String, Object> expected = new HashMap<>(); String mode = randomMode();//from ww w . ja v a 2s . c o m expected.put("columns", singletonList(columnInfo(mode, "COUNT(1)", "long", JDBCType.BIGINT, 20))); expected.put("rows", singletonList(singletonList(count))); Request request = new Request("POST", "/_xpack/sql"); if (false == mode.isEmpty()) { request.addParameter("mode", mode); } request.setJsonEntity("{\"query\": \"SELECT COUNT(*) FROM test\"}"); Map<String, Object> actual = responseToMap(client.performRequest(request)); if (false == expected.equals(actual)) { NotEqualMessageBuilder message = new NotEqualMessageBuilder(); message.compareMaps(actual, expected); fail("Response does not match:\n" + message.toString()); } }
From source file:org.xdi.oxauth.service.SessionStateService.java
public void reinitLogin(SessionState session, boolean force) { final Map<String, String> sessionAttributes = session.getSessionAttributes(); final Map<String, String> currentSessionAttributes = getCurrentSessionAttributes(sessionAttributes); if (force || !currentSessionAttributes.equals(sessionAttributes)) { sessionAttributes.putAll(currentSessionAttributes); // Reinit login sessionAttributes.put("auth_step", "1"); for (Iterator<Entry<String, String>> it = currentSessionAttributes.entrySet().iterator(); it .hasNext();) {/*from w w w . j a v a 2s . c o m*/ Entry<String, String> currentSessionAttributesEntry = it.next(); String name = currentSessionAttributesEntry.getKey(); if (name.startsWith("auth_step_passed_")) { it.remove(); } } session.setSessionAttributes(currentSessionAttributes); boolean updateResult = updateSessionState(session, true, true); if (!updateResult) { log.debug("Failed to update session entry: '{0}'", session.getId()); } } }
From source file:org.lilyproject.hadooptestfw.HBaseProxy.java
/** * Iteratively wait until no more sep events were handled. Useful for testing sep processors that cause new sep * events, which can cause even more sep events, and so on. * * See notes about {@link #waitOnReplicationPeerReady(String)} in the docs of {@link #waitOnReplication(long)} * * @param timeout/*from w w w . j ava 2 s . c om*/ * @return * @throws Exception */ public boolean waitOnSepIdle(long timeout) throws Exception { JmxLiaison jmxLiaison = new JmxLiaison(); jmxLiaison.connect(mode == HBaseProxy.Mode.EMBED); Map<String, Long> currentTimeStamp = getLastSepTimestamps(jmxLiaison); Map<String, Long> lastTimeStamp = null; int count = 0; long tryUntil = System.currentTimeMillis() + timeout; while (!currentTimeStamp.equals(lastTimeStamp)) { if (System.currentTimeMillis() > tryUntil) return false; log.debug("waiting for sep to idle, iteration " + count++); waitOnReplication(timeout); lastTimeStamp = currentTimeStamp; currentTimeStamp = getLastSepTimestamps(jmxLiaison); } return true; }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "warmedMap") public void equals_withNull(Map<Integer, Integer> map) { assertThat(map.equals(null), is(false)); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "warmedMap") public void equals_withSelf(Map<Integer, Integer> map) { assertThat(map.equals(map), is(true)); }
From source file:io.leishvl.core.test.ProvenanceTests.java
@Test public void testMongoDBMapping() throws Exception { final File testOutputDir = tmpFolder.newFolder("testMongoDBMapping"); // test with plain JSON string final String json1 = "{ \"$a1$\": \"va1\", \"_a2$\": \"va2\", \"$a3$\": { \"$b1_\": \"vb1\", \"_b2$\": \"vb2\", \"$b3_\": { \"$c1$\": \"vc1\", \"_c2_\": \"vc2\" } }, " + "\"_a4_\": \"va4\", \"$a5_\": \"va5\", \".a6$\": \"va6\", \"$a7.\": { \".b1.\": { \"_c1.\": \"vc1\" } }, \"...\": \"va8\" }"; DBObject obj = escapeMongo(json1);// w w w. j a v a2s. co m assertThat("not null DB object is created", obj, notNullValue()); String json2 = unescapeMongo(obj); assertThat("not empty JSON string is created", trim(json2), allOf(notNullValue(), not(equalTo("")))); final ObjectMapper om = new ObjectMapper(); @SuppressWarnings("unchecked") final Map<String, Object> map1 = (Map<String, Object>) (om.readValue(json1, Map.class)); @SuppressWarnings("unchecked") final Map<String, Object> map2 = (Map<String, Object>) (om.readValue(json2, Map.class)); assertThat("not null map is created from original JSON", map1, notNullValue()); assertThat("not null map is created from parsed JSON", map2, notNullValue()); assertThat("JSON strings coincide", map1.equals(map2), equalTo(true)); // additional output pw.println("\n >> -- Original JSON : " + json1); pw.println("\n >> Mapped DB Object : " + obj.toMap()); pw.println("\n >> ---- Parsed JSON : " + json2); // test with provenance document final Document prov = newObjectImportProv(newGenBankSequence("gb.123", "Sandflies"), "lvl.sf.gb.123", null); assertThat("prov document is not null", prov, notNullValue()); assertThat("prov bundle is not empty", prov.getStatementOrBundle(), allOf(notNullValue(), not(empty()))); final File file = new File(testOutputDir, "seq-gb.123.json"); provToFile(prov, file.getCanonicalPath()); assertThat("prov JSON file exists", file.exists(), equalTo(true)); assertThat("prov JSON file is not empty", file.length(), greaterThan(0l)); final String provJson = readFileToString(file, UTF_8.name()); assertThat("not empty JSON string is created", trim(provJson), allOf(notNullValue(), not(equalTo("")))); obj = escapeMongo(provJson); assertThat("not null DB object is created", obj, notNullValue()); json2 = unescapeMongo(obj); assertThat("not empty JSON string is created", trim(json2), allOf(notNullValue(), not(equalTo("")))); // additional output pw.println("\n >> -- W3C Prov JSON : " + provJson); pw.println("\n >> Mapped DB Object : " + obj.toMap()); pw.println("\n >> ---- Parsed JSON : " + json2 + "\n"); }