List of usage examples for java.lang Iterable iterator
Iterator<T> iterator();
From source file:org.apereo.openlrs.repositories.statements.ElasticSearchStatementRepository.java
@SuppressWarnings("unchecked") @Override// w ww . j ava 2 s . c o m public List<Statement> get() { Iterable<Statement> iterableStatements = esSpringDataRepository.findAll(); if (iterableStatements != null) { return IteratorUtils.toList(iterableStatements.iterator()); } return null; }
From source file:SuperStuffTest.java
/** * prueba para cargar productos por proveedor *//*from www . ja v a2s. com*/ @Test public void cargarProductosPorProveedorTest() { Pais p1 = new Pais("Colombia", "COL", "ESPAOL", Pais.SIHAYCOBERTURA); Pais p2 = new Pais("Colombia", "COL", "ESPAOL", Pais.SIHAYCOBERTURA); Set<Lugar> newPlaces = new LinkedHashSet<>(); newPlaces.add(new Lugar(p1, "Bogot", "Cedritos")); newPlaces.add(new Lugar(p1, "Bogota", "Las Orquideas")); p1.setLugares(newPlaces); repositorioPaises.save(p1); repositorioPaises.save(p2); boolean prueba = true; List<Lugar> lugares = (List<Lugar>) repositorioLugares.findAll(); superStuff.crearNuevoProveedor(new Proveedor(1, lugares.get(0), "Licorera El Tio Moe", "Calle Falsa 123", "3044463405", "www.eltiomoe.com", "eltiomoe@mail.com", "p1", "1234")); superStuff.crearNuevoProveedor(new Proveedor(2, lugares.get(0), "Jabones Mr. Chispa", "Calle Falsa 121", "3044463404", "www.mrchispa.com", "mrchispa@mail.com", "p2", "1234")); superStuff.crearNuevoProveedor(new Proveedor(3, lugares.get(0), "Alpina", "Calle Falsa 124", "3045463402", "www.prueba.com", "prueba@mail.com", "p3", "1234")); superStuff.crearNuevoProveedor(new Proveedor(4, lugares.get(0), "Ramo", "Calle Falsa 125", "3045463403", "www.prueba.com", "prueba@mail.com", "p4", "1234")); superStuff.crearNuevoProveedor(new Proveedor(5, lugares.get(0), "Telas ECI", "Calle Falsa 126", "3045463404", "www.prueba.com", "prueba@mail.com", "p5", "1234")); superStuff.crearNuevoProveedor(new Proveedor(6, lugares.get(0), "Lacteos ECI", "Calle Falsa 127", "3045463405", "www.prueba.com", "prueba@mail.com", "p6", "1234")); repositorioCategorias.save(new Categoria(1, "Frutas", "Categoria que agrupa las frutas")); repositorioCategorias.save(new Categoria(100, "Alcohol", "Categoria que agrupa Bebidas Alcoholicas")); repositorioDescuentos.save(new Descuento(0, new Date(), new Date(), "Esto es un descuento del 0%")); repositorioDescuentos.save(new Descuento(100, new Date(), new Date(), "Esto es un descuento del 10%")); Categoria c = repositorioCategorias.findOne(1); Categoria c1 = repositorioCategorias.findOne(100); Iterable<Descuento> descuentos = repositorioDescuentos.findAll(); Descuento d = descuentos.iterator().next(); Descuento d1 = descuentos.iterator().next(); Proveedor p = repositorioProveedores.findOne(1); Proveedor pr2 = repositorioProveedores.findOne(2); Proveedor pr3 = repositorioProveedores.findOne(3); Proveedor pr4 = repositorioProveedores.findOne(4); Proveedor pr5 = repositorioProveedores.findOne(5); Proveedor pr6 = repositorioProveedores.findOne(6); repositorioProductos.save(new Producto(c1, d1, p, "Jack Daniels Whiskey Old Time", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, p, "Cerveza Aguila", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, p, "Aguardiente Antioqueo", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, p, "Vino Carioso", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, p, "Aguardiente Blanco del Valle Ice", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, p, "Baileys Irish Cream", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, pr2, "A", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, pr3, "B", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, pr4, "C", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, pr5, "D", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, pr6, "E", 1000000, null)); repositorioProductos.save(new Producto(c1, d1, pr6, "F", 1000000, null)); List<Producto> producto = superStuff.cargarProductosPorProveedor(1); for (Producto producto1 : producto) { if (producto1.getProveedores().getIdProveedores() != 1) { prueba = false; } } assertTrue("Algun producto tiene un proveedor disntinto al solicitado", prueba); }
From source file:mondrian.rolap.RolapMeasureGroup.java
/** * Finds out non-joining dimensions for this measure group. * * <p>The result preserves the order in {@code otherDims}.</p> * * @param otherDims Collection of dimensions to be tested for existence in * this measure group//from w w w . j a v a 2 s. com * @return Set of dimensions that do not exist (non joining) in this cube */ public Iterable<RolapCubeDimension> nonJoiningDimensions( final Iterable<? extends RolapCubeDimension> otherDims) { return new Iterable<RolapCubeDimension>() { public Iterator<RolapCubeDimension> iterator() { //noinspection unchecked return (Iterator<RolapCubeDimension>) new FilterIterator(otherDims.iterator(), new Util.Predicate1<RolapCubeDimension>() { public boolean test(RolapCubeDimension dimension) { return !dimensionMap3.containsKey(dimension) && !dimension.isMeasures(); } }); } }; }
From source file:com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel.java
/** * Adds the matching subset of suppled credentials to the model. * * @param matcher the matcher./*from w w w . j a v a2 s . c o m*/ * @param credentials the superset of credentials. * @return {@code this} for method chaining. * @deprecated prefer using the {@link #includeMatching(Item, Class, List, CredentialsMatcher)} * or {@link #includeMatchingAs(Authentication, Item, Class, List, CredentialsMatcher)} * methods to build the list box contents in order to allow credentials providers to not have to instantiate * a full credential instance where those credential providers store the secrets external from Jenkins. */ @Deprecated @NonNull public AbstractIdCredentialsListBoxModel<T, C> withMatching(@NonNull CredentialsMatcher matcher, @NonNull Iterable<? extends C> credentials) { return withMatching(matcher, credentials.iterator()); }
From source file:com.orientechnologies.orient.graph.blueprints.GraphTest.java
@Test public void testBrokenVertex1() { OrientGraph g = new OrientGraph(URL, "admin", "admin"); try {/*from w w w .j ava 2 s.c o m*/ g.createVertexType("BrokenVertex1V"); g.createEdgeType("BrokenVertex1E"); OrientVertex vertexOne = g.addVertex("class:BrokenVertex1V"); OrientVertex vertexTwo = g.addVertex("class:BrokenVertex1V"); vertexOne.addEdge("BrokenVertex1E", vertexTwo); g.commit(); g.command(new OCommandSQL("delete from " + vertexTwo.getRecord().getIdentity() + " unsafe")).execute(); // g.command(new OCommandSQL("update BrokenVertex1E set out = null")).execute(); g.shutdown(); g = new OrientGraph(URL, "admin", "admin"); Iterable<Vertex> iterable = g.command(new OCommandSQL("select from BrokenVertex1V")).execute(); Iterator<Vertex> iterator = iterable.iterator(); int counter = 0; while (iterator.hasNext()) { OrientVertex v = (OrientVertex) iterator.next(); for (Vertex v1 : v.getVertices(Direction.OUT, "BrokenVertex1E")) { assertNotNull(((OrientVertex) v1).getRecord()); } } } finally { g.shutdown(); } }
From source file:info.magnolia.ui.dialog.setup.DialogMigrationTask.java
/** * Handle and Migrate a Dialog node.//from w ww . jav a2 s .com */ private void performDialogMigration(Node dialog) throws RepositoryException { // Get child Nodes (should be Tab) Iterable<Node> tabNodes = NodeUtil.getNodes(dialog, DIALOG_FILTER); if (tabNodes.iterator().hasNext()) { // Check if it's a tab definition if (dialog.hasProperty("controlType") && dialog.getProperty("controlType").getString().equals("tab")) { handleTab(dialog); } else { // Handle action if (!dialog.hasProperty("controlType") && !dialog.hasProperty(PROPERTY_NAME_EXTENDS) && !dialog.hasProperty(PROPERTY_NAME_REFERENCE)) { handleAction(dialog); } // Handle tab handleTabs(dialog, tabNodes.iterator()); } // Remove class property defined on Dialog level if (dialog.hasProperty("class")) { dialog.getProperty("class").remove(); } } else { // Handle as a field. handleField(dialog); } handleExtendsAndReference(dialog); }
From source file:com.orientechnologies.orient.graph.blueprints.GraphTest.java
@Test public void testGetEdgesUpdate() { OrientGraph g = new OrientGraph(URL, "admin", "admin"); try {/*from w w w .j av a 2 s .c om*/ g.createVertexType("GetEdgesUpdate"); g.createEdgeType("getEdgesUpdateEdge"); OrientVertex vertexOne = g.addVertex("class:GetEdgesUpdate"); OrientVertex vertexTwo = g.addVertex("class:GetEdgesUpdate"); OrientVertex vertexThree = g.addVertex("class:GetEdgesUpdate"); OrientVertex vertexFour = g.addVertex("class:GetEdgesUpdate"); vertexOne.addEdge("getEdgesUpdateEdge", vertexTwo); vertexOne.addEdge("getEdgesUpdateEdge", vertexThree); vertexOne.addEdge("getEdgesUpdateEdge", vertexFour); g.commit(); Iterable<Edge> iterable = vertexOne.getEdges(Direction.OUT, "getEdgesUpdateEdge"); Iterator<Edge> iterator = iterable.iterator(); int counter = 0; while (iterator.hasNext()) { iterator.next(); counter++; } Assert.assertEquals(3, counter); iterable = vertexOne.getEdges(Direction.OUT, "getEdgesUpdateEdge"); iterator = iterable.iterator(); Edge deleteEdge = (Edge) iterator.next(); Vertex deleteVertex = deleteEdge.getVertex(Direction.IN); deleteVertex.remove(); g.commit(); iterable = vertexOne.getEdges(Direction.OUT, "getEdgesUpdateEdge"); iterator = iterable.iterator(); counter = 0; while (iterator.hasNext()) { iterator.next(); counter++; } Assert.assertEquals(2, counter); } finally { g.shutdown(); } }
From source file:com.link_intersystems.lang.reflect.criteria.MemberCriteriaTest.java
@Test public void annotatedElementIterator() { Iterable<Class<?>> classIterable = new ClassCriteria().getIterable(Object.class); Iterable<? extends AnnotatedElement> iterable = memberCriteria.getAnnotatedElementIterable(classIterable); assertNotNull(iterable);/*w w w. j a v a 2s .c o m*/ Iterator<? extends AnnotatedElement> iterator = iterable.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); AnnotatedElement next = iterator.next(); assertNotNull(next); }
From source file:com.orientechnologies.orient.graph.blueprints.GraphTest.java
@Test public void testGetCompositeKeyBySingleValue() { OrientGraph g = new OrientGraph(URL, "admin", "admin"); OrientVertexType vComposite = g.createVertexType("VComposite"); vComposite.createProperty("login", OType.STRING); vComposite.createProperty("permissions", OType.EMBEDDEDSET, OType.STRING); vComposite.createIndex("VComposite_Login_Perm", OClass.INDEX_TYPE.UNIQUE, "login", "permissions"); String loginOne = "admin"; Set<String> permissionsOne = new HashSet<String>(); permissionsOne.add("perm1"); permissionsOne.add("perm2"); String loginTwo = "user"; Set<String> permissionsTwo = new HashSet<String>(); permissionsTwo.add("perm3"); permissionsTwo.add("perm4"); g.addVertex("class:VComposite", "login", loginOne, "permissions", permissionsOne); g.commit();/*from w w w .j a v a 2 s . co m*/ g.addVertex("class:VComposite", "login", loginTwo, "permissions", permissionsTwo); g.commit(); Iterable<Vertex> vertices = g.getVertices("VComposite", new String[] { "login" }, new String[] { "admin" }); Iterator<Vertex> verticesIterator = vertices.iterator(); Assert.assertTrue(verticesIterator.hasNext()); Vertex vertex = verticesIterator.next(); Assert.assertEquals(vertex.getProperty("login"), "admin"); Assert.assertEquals(vertex.getProperty("permissions"), permissionsOne); }