List of usage examples for java.util List equals
boolean equals(Object o);
From source file:org.openlegacy.terminal.mvc.rest.DefaultScreensRestController.java
/** * Special handling for REST paging next (load more style). If rows haven't changed, do not return table rows in the resulting * JSON// w ww.j a v a2s .c om * * @param entityName * @param json * @param response * @return * @throws IOException */ @RequestMapping(value = "/{entity}", method = RequestMethod.POST, consumes = JSON, params = "action=next") public ModelAndView postNextJson(@PathVariable("entity") String entityName, @RequestParam(value = "children", required = false, defaultValue = "true") boolean children, @RequestBody String json, HttpServletResponse response) throws IOException { if (!resetRowsWhenSameOnNext) { return super.postEntityJson(entityName, "next", children, json, response); } preSendJsonEntity(entityName, null, json, response); ScreenEntity entity = terminalSession.getEntity(); Object resultEntity = sendEntity(entity, "next"); if (enableIncrementalLoading) { List<?> beforeRecords = ScrollableTableUtil.getSingleScrollableTable(tablesDefinitionProvider, entity); List<?> afterRecords = ScrollableTableUtil.getSingleScrollableTable(tablesDefinitionProvider, resultEntity); if (afterRecords.equals(beforeRecords)) { afterRecords.clear(); } } return getEntityInner(resultEntity, false); }
From source file:com.alibaba.otter.shared.arbitrate.impl.setl.zookeeper.monitor.StageMonitor.java
/** * ?processId?/*ww w . ja v a 2 s .c o m*/ */ private void syncStage(final Long processId) { // 1. ?pipelineId + processIdpath String path = null; try { path = StagePathUtils.getProcess(getPipelineId(), processId); // 2. ??process? IZkConnection connection = zookeeper.getConnection(); // zkclient?zk?lock??watcher?zk? ZooKeeper orginZk = ((ZooKeeperx) connection).getZookeeper(); List<String> currentStages = orginZk.getChildren(path, new AsyncWatcher() { public void asyncProcess(WatchedEvent event) { MDC.put(ArbitrateConstants.splitPipelineLogFileKey, String.valueOf(getPipelineId())); if (isStop()) { return; } if (event.getType() == EventType.NodeDeleted) { processTermined(processId); // ? return; } // session expired/connection losscase?watcher???watcher?watcher? boolean dataChanged = event.getType() == EventType.NodeDataChanged || event.getType() == EventType.NodeDeleted || event.getType() == EventType.NodeCreated || event.getType() == EventType.NodeChildrenChanged; if (dataChanged) { // boolean reply = initStage(processId); // if (reply == false) {// load??????? syncStage(processId); // } } } }); Collections.sort(currentStages, new StageComparator()); List<String> lastStages = this.currentStages.get(processId); if (lastStages == null || !lastStages.equals(currentStages)) { initProcessStage(processId); // ? } } catch (NoNodeException e) { processTermined(processId); // ? } catch (KeeperException e) { syncStage(processId); } catch (InterruptedException e) { // ignore } }
From source file:org.trnltk.web.training.TrainingSetCreatorParserSelectionTest.java
@Test @Ignore/*w w w . j av a 2 s. c o m*/ public void shouldMatchExpectations() throws IOException { boolean hasError = false; final List<Pair<String, List<String>>> entries = getEntries(); final MorphologicParser morphologicParser = createParser(); for (Pair<String, List<String>> entry : entries) { final String surface = entry.getLeft(); final List<String> expectedParseResult = entry.getRight(); final List<MorphemeContainer> morphemeContainers = morphologicParser.parseStr(surface); final List<String> retrieved = new ArrayList<String>( MorphemeContainerFormatter.formatMorphemeContainers(morphemeContainers)); Collections.sort(retrieved, parseResultOrdering); if (!expectedParseResult.equals(retrieved)) { System.out.println("W " + surface); System.out.println("Expected"); for (String s : expectedParseResult) { System.out.println("- " + s); } System.out.println("Retrieved"); for (String s : retrieved) { System.out.println("- " + s); } hasError = true; } } if (hasError) fail(); }
From source file:saschpe.birthdays.fragment.SourcesFragment.java
private void storeSelectedAccountsAndSync() { Log.i(TAG, "Store selected accounts and sync..."); List<Account> contactAccountWhiteList = new ArrayList<>(); for (int i = 0; i < adapter.getItemCount(); i++) { AccountModel item = adapter.getItem(i); if (!item.isSelected()) { contactAccountWhiteList.add(item.getAccount()); }/* ww w.j a va2s . c om*/ } if (PreferencesHelper.getFirstRun(getActivity()) || !contactAccountWhiteList.equals(AccountProviderHelper.getAccountList(getActivity()))) { PreferencesHelper.setFirstRun(getActivity(), false); AccountProviderHelper.setAccountList(getActivity(), contactAccountWhiteList); LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent(MainActivity.ACTION_SYNC_REQUESTED)); } }
From source file:org.nuclos.client.ui.collect.model.SortableCollectableTableModelImpl.java
@Deprecated private void ensureMaxColumnSortKeys(final int maxColumn) { List<? extends SortKey> currentSortKeys = getSortKeys(); List<SortKey> newSortKeys = CollectionUtils.applyFilter(currentSortKeys, new Predicate<SortKey>() { @Override//from w w w . j a v a 2 s. c om public boolean evaluate(SortKey x) { return x.getColumn() < maxColumn; } }); if (!newSortKeys.equals(currentSortKeys)) { setSortKeys(newSortKeys, false); } }
From source file:com.ibm.jaggr.core.impl.modulebuilder.javascript.RequireExpansionCompilerPass.java
/** * Recursively called to process AST nodes looking for require calls. If a * require call is found, then the dependency list is expanded to include * nested dependencies. The set of nested dependencies is obtained from the * config object and is trimmed so as not to include enclosing dependencies * (dependencies specified in the enclosing define or any enclosing require * calls.//from w ww . j a v a2s . c om * * @param node * The node being processed * @param enclosingDependencies * The set of dependencies specified by enclosing define or * require calls. * @throws IOException */ public void processChildren(Node node, List<DependencyList> enclosingDependencies) throws IOException { for (Node cursor = node.getFirstChild(); cursor != null; cursor = cursor.getNext()) { Node dependencies = null; if ((dependencies = NodeUtil.moduleDepsFromRequire(cursor)) != null) { enclosingDependencies = new LinkedList<DependencyList>(enclosingDependencies); expandRequireList(dependencies, enclosingDependencies, logDebug ? MessageFormat.format(Messages.RequireExpansionCompilerPass_0, new Object[] { cursor.getLineno() }) : null, true); } else if ((dependencies = NodeUtil.moduleDepsFromConfigDeps(cursor, configVarName)) != null) { expandRequireList(dependencies, new LinkedList<DependencyList>(), logDebug ? MessageFormat.format(Messages.RequireExpansionCompilerPass_2, new Object[] { cursor.getLineno() }) : null, false); } else if ((dependencies = NodeUtil.moduleDepsFromDefine(cursor)) != null) { String moduleName = cursor.getFirstChild().getProp(Node.SOURCENAME_PROP).toString(); if (aggregator.getOptions().isDevelopmentMode() && aggregator.getOptions().isVerifyDeps()) { // Validate dependencies for this module by comparing the // declared dependencies against the dependencies that were // used to calculate the dependency graph. Node strNode = dependencies.getFirstChild(); List<String> deps = new ArrayList<String>(); while (strNode != null) { if (strNode.getType() == Token.STRING) { String mid = strNode.getString(); if (!PathUtil.invalidChars.matcher(mid).find()) { // ignore names with invalid characters deps.add(strNode.getString()); } } strNode = strNode.getNext(); } int idx = moduleName.lastIndexOf("/"); //$NON-NLS-1$ String ref = (idx == -1) ? "" : moduleName.substring(0, idx); //$NON-NLS-1$ List<String> normalized = Arrays .asList(PathUtil.normalizePaths(ref, deps.toArray(new String[deps.size()]))); // Run the list through a linked hash set to remove duplicate entries, yet keep list ordering Set<String> temp = new LinkedHashSet<String>(normalized); normalized = Arrays.asList(temp.toArray(new String[temp.size()])); List<String> processedDeps = aggregator.getDependencies().getDelcaredDependencies(moduleName); if (processedDeps != null && !processedDeps.equals(normalized)) { // The dependency list for this module has changed since the dependencies // were last created/validated. Throw an exception. throw new DependencyVerificationException(moduleName); } } // Add the expanded dependencies to the set of enclosing dependencies for // the module. List<String> moduleDeps = aggregator.getDependencies().getDelcaredDependencies(moduleName); if (moduleDeps != null) { enclosingDependencies = new LinkedList<DependencyList>(enclosingDependencies); DependencyList depList = new DependencyList(moduleName, moduleDeps, aggregator, hasFeatures, true, // resolveAliases logDebug); depList.setLabel(MessageFormat.format(Messages.RequireExpansionCompilerPass_1, new Object[] { cursor.getLineno() })); enclosingDependencies.add(depList); } } // Recursively call this method to process the child nodes if (cursor.hasChildren()) processChildren(cursor, enclosingDependencies); } }
From source file:org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils.java
public static void getGeneralInfoForTags(ResourceReqDetails resource, User user) { clickMore();//from w w w .j a va 2 s . co m String componentType = waitFunctionForaGetElements("componentType", 3).getText(); String version = waitFunctionForaGetElements("version", 3).getText(); String category = waitFunctionForaGetElements("category", 3).getText();// get // right // panel // Category. String resourceType = waitFunctionForaGetElements("resourceType", 3).getText();// get // right // panel // SubCategory. String date = GeneralUIUtils.getEelementByClassName("creationDate").getText(); String aouthor = waitfunctionforallelements("author'").getText(); String vendorName = waitFunctionForaGetElements("vendorName", 3).getText(); String vendorRelease = waitFunctionForaGetElements("vendorRelease", 3).getText(); String contactId = waitFunctionForaGetElements("contactId", 3).getText(); String description = waitFunctionForaGetElements("description", 3).getText(); List<WebElement> tags = GeneralUIUtils.waitForElementsListVisibility("tag"); assertTrue(componentType.equals("RESOURCE")); assertTrue(version.equals(resource.getVersion())); assertTrue(category.equals(resource.getCategories().get(0).getName())); assertEquals(resourceType, resource.getResourceType()); // assertEquals(Date,resource.getCreationDate()); // assertEquals(Aouthor,resource.getCreatorFullName()); assertTrue(vendorName.equals(resource.getVendorName())); assertTrue(vendorRelease.equals(resource.getVendorRelease())); assertTrue(contactId.equals(resource.getContactId())); assertTrue(description.equals(resource.getDescription() + "\nLess")); assertTrue(tags.equals("Tag-150")); }
From source file:org.talend.dataprep.transformation.actions.text.SplitTest.java
@Test /**/*from w ww . j a va 2 s .c o m*/ * @see SplitTest#should_split_row() */ public void test_TDP_876() { // given final DataSetRow row = builder() // .with(value("lorem bacon").type(Type.STRING)) // .with(value("Bacon ipsum dolor amet swine leberkas pork belly").type(Type.STRING)) // .with(value("01/01/2015").type(Type.STRING)) // .build(); // when ActionTestWorkbench.test(Collections.singletonList(row), // analyzerService, // Test requires some analysis in asserts actionRegistry, factory.create(action, parameters)); // then final RowMetadata actual = row.getRowMetadata(); Statistics originalStats = actual.getById("0001").getStatistics(); final List<PatternFrequency> originalPatterns = originalStats.getPatternFrequencies(); assertFalse(originalPatterns.equals(actual.getById("0003").getStatistics().getPatternFrequencies())); assertFalse(originalPatterns.equals(actual.getById("0004").getStatistics().getPatternFrequencies())); }
From source file:com.smartitengineering.event.hub.spi.hbase.HBaseHubPersistorITCase.java
@Test public void testGetEvents() { System.out.println("--------------------- Test GetEvents ---------------------"); final HubPersistentStorer storer = HubPersistentStorerSPI.getInstance().getStorer(); Assert.assertTrue(storer.getEvents("-1", null, 0).size() == 0); Assert.assertTrue(storer.getEvents(" ", " ", 0).size() == 0); Assert.assertTrue(storer.getEvents(null, null, 0).size() == 0); Assert.assertTrue(storer.getEvents("1", null, 0).size() == 0); final String content = "<xml>some xml</xml>"; final String contentType = "application/xml"; Channel dummyChannel = APIFactory.getChannelBuilder("someName").build(); Event event1 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(dummyChannel, event1); Event event2 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(dummyChannel, event2); Event event3 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(dummyChannel, event3); Event event4 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); event4 = storer.create(dummyChannel, event4); final Long placeholderId = NumberUtils.toLong(event4.getPlaceholderId(), 0); System.out.println("Selected PlaceholderID: " + placeholderId); Event event5 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(dummyChannel, event5); Event event6 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(dummyChannel, event6); Event event7 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(dummyChannel, event7); final Comparator<Event> comparator = new Comparator<Event>() { @Override/* w w w . j a va 2 s. c om*/ public int compare(Event o1, Event o2) { if (o1 == null && o2 == null) { return 0; } else { if (o1 == null && o2 != null) { return 1; } else { if (o1 != null && o2 == null) { return -1; } else { final int compareTo = new Long(NumberUtils.toLong(o1.getPlaceholderId())) .compareTo(NumberUtils.toLong(o2.getPlaceholderId())); return compareTo; } } } } }; final int count = 3; Collection<Event> events = storer.getEvents(placeholderId.toString(), null, count); Assert.assertNotNull(events); Assert.assertTrue(events.size() == count); List<Event> sortTestList = new ArrayList<Event>(events); Collections.sort(sortTestList, comparator); List<Event> origList = new ArrayList<Event>(events); System.out.println("*** EVENTS: " + origList + " " + sortTestList); Assert.assertTrue(origList.equals(sortTestList)); Assert.assertEquals(Long.toString(placeholderId - 1), origList.get(origList.size() - 1).getPlaceholderId()); events = storer.getEvents(placeholderId.toString(), "\t", -1 * count); Assert.assertNotNull(events); Assert.assertTrue(events.size() == count); sortTestList = new ArrayList<Event>(events); Collections.sort(sortTestList, comparator); origList = new ArrayList<Event>(events); System.out.println(origList + " " + sortTestList); Assert.assertTrue(origList.equals(sortTestList)); Assert.assertEquals(Long.toString(placeholderId + 1), origList.get(0).getPlaceholderId()); events = storer.getEvents(placeholderId.toString(), dummyChannel.getName(), -1 * count); Assert.assertNotNull(events); Assert.assertEquals(Math.abs(count), events.size()); sortTestList = new ArrayList<Event>(events); Collections.sort(sortTestList, comparator); origList = new ArrayList<Event>(events); System.out.println(origList + " " + sortTestList); Assert.assertTrue(origList.equals(sortTestList)); Assert.assertEquals(Long.toString(placeholderId + 1), origList.get(0).getPlaceholderId()); }
From source file:com.smartsheet.api.internal.json.JacksonJsonSerializerTest.java
@Test public void testDeserializeList() throws JsonParseException, IOException, JSONSerializerException { // Test null pointer exceptions try {// w ww. j a v a 2s . c o m jjs.deserializeList(null, null); fail("Exception should have been thrown."); } catch (IllegalArgumentException e) { // expected } try { jjs.deserializeList(ArrayList.class, null); fail("Exception should have been thrown."); } catch (IllegalArgumentException e) { // expected } try { jjs.deserializeList(null, new ByteArrayInputStream(new byte[10])); fail("Exception should have been thrown."); } catch (IllegalArgumentException e) { // expected } // Test JsonParseException. Can't convert an invalid json array to a list. try { jjs.deserializeList(List.class, new ByteArrayInputStream("[broken jason".getBytes())); fail("Should have thrown a JsonParseException"); } catch (JSONSerializerException e) { // Expected } // Serialize a User and fail since it is not an ArrayList ByteArrayOutputStream b = new ByteArrayOutputStream(); User originalUser = new User(); jjs.serialize(originalUser, b);//b has the user in json format in a byte array try { jjs.deserializeList(ArrayList.class, new ByteArrayInputStream(b.toByteArray())); fail("Exception should have been thrown."); } catch (JSONSerializerException ex) { //expected } // Test serializing/deserializing a simple ArrayList jjs = new JacksonJsonSerializer(); List<String> originalList = new ArrayList<String>(); originalList.add("something"); originalList.add("something-else"); b = new ByteArrayOutputStream(); jjs.serialize(originalList, b); List<String> newList = jjs.deserializeList(String.class, new ByteArrayInputStream(b.toByteArray())); // Verify that the serialized/deserialized object is equal to the original object. if (!newList.equals(originalList)) { fail("Types should be identical. Serialization/Deserialation might have failed."); } // Test JSONSerializerException // Test IOException try { FileInputStream fis = new FileInputStream(File.createTempFile("json_test", ".tmp")); fis.close(); jjs.deserializeList(List.class, fis); fail("Should have thrown an IOException"); } catch (JSONSerializerException ex) { //expected } }