List of usage examples for java.util List containsAll
boolean containsAll(Collection<?> c);
From source file:com.nextdoor.bender.operation.conditional.ConditionalOperationTest.java
@Test public void testSingleConditionNoMatch() { /*/* w ww . j a v a 2s.co m*/ * Setup the pipeline of operation processors */ List<Pair<FilterOperation, List<OperationProcessor>>> conditions = new ArrayList<Pair<FilterOperation, List<OperationProcessor>>>(); List<OperationProcessor> case1Ops = new ArrayList<OperationProcessor>(); DummyAppendOperationFactory pos = new DummyAppendOperationFactory(); DummyAppendOperationConfig posConf = new DummyAppendOperationConfig(); posConf.setAppendStr("+"); pos.setConf(posConf); case1Ops.add(new OperationProcessor(pos)); FilterOperation filter = new BasicFilterOperation(false); conditions.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(filter, case1Ops)); ConditionalOperation op = new ConditionalOperation(conditions, false); /* * Create thread that supplies input events */ Queue<InternalEvent> inputQueue = new Queue<InternalEvent>(); supply(2, inputQueue); /* * Process */ Stream<InternalEvent> input = inputQueue.stream(); Stream<InternalEvent> output = op.getOutputStream(input); List<String> actual = output.map(m -> { return m.getEventObj().getPayload().toString(); }).collect(Collectors.toList()); List<String> expected = Arrays.asList("0", "1"); assertEquals(2, actual.size()); assertTrue(expected.containsAll(actual)); }
From source file:org.ebayopensource.turmeric.eclipse.typelibrary.ui.TypeLibraryUtil.java
/** * Import types to type library.// www . ja v a 2 s.c o m * * @param types the types * @param tlProjectName the tl project name * @param monitor the monitor */ public static void importTypesToTypeLibrary(List<ImportTypeModel> types, String tlProjectName, IProgressMonitor monitor) { List<ImportTypeModel> allResolvedModel = new ArrayList<ImportTypeModel>(); List<ImportTypeModel> resolvedModel = new ArrayList<ImportTypeModel>(); do { resolvedModel.clear(); for (ImportTypeModel importModel : types) { if (allResolvedModel.containsAll(importModel.getDependencies().values()) == false) { // dependency not resolved yet. continue; } TypeParamModel model = importModel.getTypeModel(); if (model instanceof ComplexTypeParamModel == true) { ComplexTypeParamModel cModel = (ComplexTypeParamModel) model; ComplexTypeWizardElementPage.ElementTableModel[] elements = cModel.getElementTableModel(); try { for (ComplexTypeWizardElementPage.ElementTableModel element : elements) { Object eleType = element.getRawElementType(); if (eleType instanceof QName) { QName keyDepQName = (QName) eleType; ImportTypeModel depModel = importModel.getDependencies().get(keyDepQName); QName depQName = new QName(depModel.getNamespace(), depModel.getName()); LibraryType depType = SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry() .getType(depQName); if (depType == null) { throw new ImportTypeException("Failed to resolve \"" + cModel.getTypeName() + "\" type dependency:" + depQName); } element.setDatatype(depType); } } if (model instanceof ComplexTypeCCParamModel) { ComplexTypeCCParamModel ccModel = (ComplexTypeCCParamModel) model; Object baseType = ccModel.getBaseType(); if (baseType instanceof QName) { QName keyDepQName = (QName) baseType; ImportTypeModel depModel = importModel.getDependencies().get(keyDepQName); QName depQName = new QName(depModel.getNamespace(), depModel.getName()); LibraryType depType = SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry() .getType(depQName); if (depType == null) { throw new ImportTypeException("Failed to resolve \"" + cModel.getTypeName() + "\" type dependency:" + depQName); } ccModel.setBaseType(depType); } } } catch (Exception e) { SOALogger.getLogger().error(e); UIUtil.showErrorDialog(e); } } monitor.subTask(" -> " + model.getTypeName()); model.setTypeLibraryName(tlProjectName); try { TypeCreator.createType(model, monitor); // invoke this when a type is created, for dependency // need BuildSystemUtil.updateSOAClasspathContainer(WorkspaceUtil.getProject(tlProjectName)); monitor.subTask(" -> Calling code gen for type generation: " + model.getTypeName()); ProgressUtil.progressOneStep(monitor); final IProject project = WorkspaceUtil.getProject(model.getTypeLibraryName()); final String typeLibName = model.getTypeLibraryName(); final String typeName = model.getTypeName(); final String version = model.getVersion(); try { TypeCreator.callCodegen(project, typeLibName, typeName); ProgressUtil.progressOneStep(monitor); WorkspaceUtil.refresh(project); ProgressUtil.progressOneStep(monitor); String xsdFileName = TypeLibraryUtil.getXsdFileLocation(typeName, project); ProgressUtil.progressOneStep(monitor); TypeCreator.postProcessTypeCreation(typeName, version, typeLibName, project.getFile(xsdFileName), false, false); TypeLibraryUtil.refreshTypeDependencyInSOATypeRegistry(tlProjectName); } catch (Exception e) { SOALogger.getLogger().error(e); throw new SOATypeCreationFailedException("Failed to import schema type", e); } } catch (Exception e) { SOALogger.getLogger().error(e); UIUtil.showErrorDialog("Error Occurs", "Error Occurs during type creation", e); return; } resolvedModel.add(importModel); ProgressUtil.progressOneStep(monitor); } allResolvedModel.addAll(resolvedModel); types.removeAll(resolvedModel); } while (resolvedModel.size() > 0); }
From source file:com.nextdoor.bender.operation.conditional.ConditionalOperationTest.java
@Test public void testSingleConditionMatch() { /*//from w w w. jav a 2s . co m * Setup the pipeline of operation processors */ List<Pair<FilterOperation, List<OperationProcessor>>> conditions = new ArrayList<Pair<FilterOperation, List<OperationProcessor>>>(); List<OperationProcessor> case1Ops = new ArrayList<OperationProcessor>(); DummyAppendOperationFactory pos = new DummyAppendOperationFactory(); DummyAppendOperationConfig posConf = new DummyAppendOperationConfig(); posConf.setAppendStr("+"); pos.setConf(posConf); case1Ops.add(new OperationProcessor(pos)); FilterOperation filter = new BasicFilterOperation(true); conditions.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(filter, case1Ops)); ConditionalOperation op = new ConditionalOperation(conditions, false); /* * Create thread that supplies input events */ Queue<InternalEvent> inputQueue = new Queue<InternalEvent>(); supply(2, inputQueue); /* * Process */ Stream<InternalEvent> input = inputQueue.stream(); Stream<InternalEvent> output = op.getOutputStream(input); List<String> actual = output.map(m -> { return m.getEventObj().getPayload().toString(); }).collect(Collectors.toList()); List<String> expected = Arrays.asList("0+", "1+"); assertEquals(2, actual.size()); assertTrue(expected.containsAll(actual)); }
From source file:com.griddynamics.banshun.DependencySorter.java
private List<Location> pullLocationListTail(Deque<Location> locations) { LinkedList<Location> resolvedLocations = new LinkedList<>(); List<String> annihilatedExports = new LinkedList<>(); for (Iterator<Location> it = locations.descendingIterator(); it.hasNext();) { Location location = it.next(); if (annihilatedExports.containsAll(location.getExportBeanNames())) { it.remove(); //remove location from unresolved resolvedLocations.addFirst(location); for (BeanReferenceInfo imp : location.importBeans) { if (isSomewhereImported(locations, imp)) { annihilatedExports.add(imp.getServiceName()); }/*from ww w . ja v a2 s . c om*/ } it = locations.descendingIterator(); //reset iterator } } return resolvedLocations; }
From source file:cz.swi2.mendeluis.dataaccesslayer.domain.FavouriteItemTest.java
@org.testng.annotations.Test public void testGetAll() { // Create favitem FavouriteItem f1 = new FavouriteItem("Food menu xx"); FavouriteItem f2 = new FavouriteItem("Food menu xx 2"); // Insert favitem this.favouriteItemRepository.insert(f1); this.favouriteItemRepository.insert(f2); // Fetch all favitems List<FavouriteItem> results = this.favouriteItemRepository.getAll(); // Prepare a list to be compared List<FavouriteItem> fav = new ArrayList(); fav.add(f1);/*w w w . j a v a 2 s . c o m*/ fav.add(f2); // We do not use a different db for testing. Thefore we must test only matching items, not all. assertTrue(results.containsAll(fav)); }
From source file:es.upm.fi.dia.oeg.ogsadai.sparql.optimizers.WellDesignedRule1Optimiser.java
/** * checks safe condition (variables in P1 are in P2 and P') * /*w ww .j a va 2 s. c o m*/ * @param filterSelectOperator * * @param optionalOperator * (P1 OPT P2) * * @return true if pattern is safe */ private boolean checkSafeCondition(Operator filterSelectOperator, Operator optionalOperator) { List<String> pPrimeAttrs = new ArrayList<String>(); // getting variables from left side of AND (parent operator) for (Attribute attribute : ((SelectOperator) filterSelectOperator).getUsedAttributes()) { pPrimeAttrs.add(attribute.getName()); } // getting variables from P2 List<String> p2Attrs = new ArrayList<String>(); for (Attribute attribute : optionalOperator.getChild(1).getHeading().getAttributes()) { p2Attrs.add(attribute.getName()); } // p2Attrs.addAll(pPrimeAttrs); List<String> intersection = null; intersection = new ArrayList<String>(); intersection = ListUtils.intersection(pPrimeAttrs, p2Attrs); // getting variables from P2 List<String> p1Attrs = new ArrayList<String>(); for (Attribute attribute : optionalOperator.getChild(0).getHeading().getAttributes()) { p1Attrs.add(attribute.getName()); } if (p1Attrs.containsAll(pPrimeAttrs)) { return true; } return false; }
From source file:grakn.core.graql.reasoner.GeoInferenceIT.java
@Test public void testLazy() { try (TransactionOLTP tx = geoGraphSession.transaction().write()) { String queryString = "match (geo-entity: $x, entity-location: $y) isa is-located-in; get; limit 1;"; String queryString2 = "match (geo-entity: $x, entity-location: $y) isa is-located-in; get; limit 22;"; String queryString3 = "match (geo-entity: $x, entity-location: $y) isa is-located-in; get;"; List<ConceptMap> answers = tx.execute(Graql.parse(queryString).asGet()); List<ConceptMap> answers2 = tx.execute(Graql.parse(queryString2).asGet()); List<ConceptMap> answers3 = tx.execute(Graql.parse(queryString3).asGet()); assertTrue(answers3.containsAll(answers)); assertTrue(answers3.containsAll(answers2)); }/*from www . j a va 2s . co m*/ }
From source file:cc.kave.episodes.mining.evaluation.PatternsIdentifier.java
public void trainingCode(int numbRepos, int frequency, double entropy) throws Exception { List<List<Fact>> stream = streamParser.parseStream(numbRepos); List<Event> events = mappingParser.parse(numbRepos); // Logger.log("Number of events: %d", events.size()); Map<Integer, Set<Episode>> postpEpisodes = episodeProcessor.postprocess(numbRepos, frequency, entropy); Map<Integer, Set<Episode>> patterns = maxEpisodes.getMaximalEpisodes(postpEpisodes); // checkMethodSize(stream, events); for (Map.Entry<Integer, Set<Episode>> entry : patterns.entrySet()) { if (entry.getKey() < 2) { continue; }/*from www.j a va 2 s . co m*/ // Episode debug = createDebuggingEpisode(); for (Episode episode : entry.getValue()) { Set<Fact> episodeFacts = episode.getEvents(); EnclosingMethods methodsOrderRelation = new EnclosingMethods(true); for (List<Fact> method : stream) { if (method.size() < 3) { continue; } if (method.containsAll(episodeFacts)) { methodsOrderRelation.addMethod(episode, method, events); // if (episode.equals(debug)) { // Logger.log("Method: %s\noccurrence: %d", // method.toString(), // methodsOrderRelation.getOccurrences()); // } } } if (methodsOrderRelation.getOccurrences() < episode.getFrequency()) { Logger.log("Episode: %s", episode.toString()); Logger.log("Frequency = %d, occurrence = %d", episode.getFrequency(), methodsOrderRelation.getOccurrences()); throw new Exception("Episode is not found sufficient number of times on the training stream!"); } } Logger.log("Processed %d-node patterns!", entry.getKey()); } Logger.log("All patterns are identified in the training data!"); }
From source file:com.tilab.fiware.metaware.service.UserServiceTest.java
/** * Test of getUsersList method, of class UserService. * * @throws com.fasterxml.jackson.core.JsonProcessingException * @throws java.security.NoSuchAlgorithmException *///ww w . j a v a 2 s.c o m @Test public void testGetUsersList() throws JsonProcessingException, NoSuchAlgorithmException { System.out.println("getUsersList"); UserService instance = INSTANCE.getUserService(); compId = INSTANCE.getCompanyService().createCompany(comp); dep.setCompany(compId); depId = INSTANCE.getDepartmentService().createDepartment(dep); user1.setDepartment(depId); user1.setCompany(compId); userId1 = instance.createUser(user1); user2.setDepartment(depId); user2.setCompany(compId); userId2 = instance.createUser(user2); List<User> expResult = new ArrayList<>(); expResult.add(user1); expResult.add(user2); List<User> result = instance.getUsersList(); assertTrue(expResult.containsAll(result) && result.containsAll(expResult)); INSTANCE.getCompanyService().deleteCompany(compId); INSTANCE.getDepartmentService().deleteDepartment(depId); instance.deleteUser(userId1); instance.deleteUser(userId2); }
From source file:com.nextdoor.bender.operation.conditional.ConditionalOperationTest.java
@Test public void testTwoConditionsNoMatch() { List<Pair<FilterOperation, List<OperationProcessor>>> conditions = new ArrayList<Pair<FilterOperation, List<OperationProcessor>>>(); /*//from w w w.j a v a 2 s .c o m * Case 1 */ List<OperationProcessor> case1Ops = new ArrayList<OperationProcessor>(); DummyAppendOperationFactory pos = new DummyAppendOperationFactory(); DummyAppendOperationConfig posConf = new DummyAppendOperationConfig(); posConf.setAppendStr("+"); pos.setConf(posConf); case1Ops.add(new OperationProcessor(pos)); FilterOperation case1Filter = new BasicFilterOperation(false); conditions.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(case1Filter, case1Ops)); /* * Case 2 */ List<OperationProcessor> case2Ops = new ArrayList<OperationProcessor>(); DummyAppendOperationFactory neg = new DummyAppendOperationFactory(); DummyAppendOperationConfig negConf = new DummyAppendOperationConfig(); negConf.setAppendStr("-"); neg.setConf(negConf); case2Ops.add(new OperationProcessor(neg)); FilterOperation case2Filter = new BasicFilterOperation(false); conditions.add(new ImmutablePair<FilterOperation, List<OperationProcessor>>(case2Filter, case2Ops)); ConditionalOperation op = new ConditionalOperation(conditions, false); /* * Create thread that supplies input events */ Queue<InternalEvent> inputQueue = new Queue<InternalEvent>(); supply(2, inputQueue); /* * Process */ Stream<InternalEvent> input = inputQueue.stream(); Stream<InternalEvent> output = op.getOutputStream(input); List<String> actual = output.map(m -> { return m.getEventObj().getPayload().toString(); }).collect(Collectors.toList()); List<String> expected = Arrays.asList("0", "1"); assertEquals(2, actual.size()); assertTrue(expected.containsAll(actual)); }