Example usage for java.lang Iterable iterator

List of usage examples for java.lang Iterable iterator

Introduction

In this page you can find the example usage for java.lang Iterable iterator.

Prototype

Iterator<T> iterator();

Source Link

Document

Returns an iterator over elements of type T .

Usage

From source file:nl.elucidator.maven.analyzer.database.model.ArtifactNodeTest.java

@Test
@Transactional//from w  w  w.  jav  a 2s . c  om
public void versionRelations() {

    ArtifactNode artifactNode = new ArtifactNode(makeArtifact("groupIdB:artifactIdB:1.0"));
    artifactNode = template.save(artifactNode);

    VersionNode versionNode1_0 = new VersionNode(
            makeArtifact(artifactNode.getGroupId() + ":" + artifactNode.getArtifactId() + ":" + "1.0"));
    versionNode1_0 = template.save(versionNode1_0);
    template.save(versionNode1_0);
    artifactNode.addVersion(versionNode1_0);

    VersionNode versionNode1_1 = new VersionNode(
            makeArtifact(artifactNode.getGroupId() + ":" + artifactNode.getArtifactId() + ":" + "1.1"));
    versionNode1_1 = template.save(versionNode1_1);
    template.save(versionNode1_1);
    artifactNode.addVersion(versionNode1_1);
    template.save(artifactNode);

    ArtifactNode retrieved = this.artifactRepository.findByGa(artifactNode.getGa());

    Iterable<VersionNode> versionRelations = retrieved.getVersionNodes();
    assertTrue(versionRelations.iterator().hasNext());
    for (VersionNode versionNode : versionRelations) {
        assertTrue(versionNode.getVersion().equals("1.0") || versionNode.getVersion().equals("1.1"));
    }
}

From source file:edu.pitt.dbmi.ccd.anno.group.GroupResourceAssembler.java

/**
 * convert Groups to GroupResources/*from  w  w  w .  jav  a  2s .  c  o m*/
 *
 * @param groups entities
 * @return List of resources
 */
@Override
public List<GroupResource> toResources(Iterable<? extends Group> groups) throws IllegalArgumentException {
    // Assert groups is not empty
    Assert.isTrue(groups.iterator().hasNext());
    return StreamSupport.stream(groups.spliterator(), false).map(this::toResource).collect(Collectors.toList());
}

From source file:com.github.rvesse.airline.builder.GroupBuilder.java

public GroupBuilder<C> withCommands(Iterable<Class<? extends C>> commands) {
    this.commands.addAll(IteratorUtils.toList(commands.iterator()));
    return this;
}

From source file:edu.pitt.dbmi.ccd.anno.access.AccessResourceAssembler.java

/**
 * Convert Accesses to AccessResources/*  w  ww .j  a v a 2  s.c  o  m*/
 *
 * @param accesses entities
 * @return list of resources
 */
@Override
public List<AccessResource> toResources(Iterable<? extends Access> accesses) throws IllegalArgumentException {
    // Assert accesses is not empty
    Assert.isTrue(accesses.iterator().hasNext());
    return StreamSupport.stream(accesses.spliterator(), false).map(this::toResource)
            .collect(Collectors.toList());
}

From source file:com.infinities.nova.images.api.DaseinImagesApi.java

@Override
public List<Image> getAll(OpenstackRequestContext context, ImagesFilter filters, PaginationParams pageParams)
        throws Exception {
    if (context == null) {
        context = Context.getAdminContext("no");
    }/* w  w  w. j  a v a 2 s.c om*/

    AsyncResult<Iterable<MachineImage>> result = getSupport(context.getProjectId())
            .listImages(ImageFilterOptions.getInstance());
    Iterable<MachineImage> iterable = result.get();
    Iterator<MachineImage> iterator = iterable.iterator();

    List<Image> images = new ArrayList<Image>();
    while (iterator.hasNext()) {
        MachineImage machineImage = iterator.next();
        images.add(toImage(machineImage));
    }

    return images;
}

From source file:com.ewerk.prototype.persistence.repositories.PersonRepositoryCustomIntegTest.java

@Test
public void testLocate() {
    personRepository.deleteAll();/*  w w w  .  jav  a2s .  c  om*/
    Person created = personRepositoryCustom.create(john);

    final Iterable<Person> persons = personRepositoryCustom.locate("Smith", "John");
    assertThat(persons).hasSize(1);
    assertThat(persons.iterator().next()).isEqualTo(created);
}

From source file:de.msg.repository.RouteRepositoryImplJpaTest.java

@Test
public void findAll() throws Exception {
    Iterable<Route> actual = repository.findAll();
    Assert.assertNotNull(actual.iterator().hasNext());
}

From source file:com.infinities.nova.flavors.api.DaseinFlavorsApi.java

@Override
public List<Flavor> getAllFlavorsSortedList(OpenstackRequestContext context, FlavorsFilter filter,
        String sortKey, String sortDir, Integer limit, String marker) throws Exception {
    if (context == null) {
        context = Context.getAdminContext("no");
    }/*w  w w. j  ava  2s. c o  m*/

    AsyncResult<Iterable<VirtualMachineProduct>> result = getSupport(context.getProjectId()).listAllProducts();
    Iterable<VirtualMachineProduct> iterable = result.get();
    Iterator<VirtualMachineProduct> iterator = iterable.iterator();
    List<Flavor> instTypes = new ArrayList<Flavor>();
    while (iterator.hasNext()) {
        VirtualMachineProduct product = iterator.next();
        Flavor type = toFlavor(product);
        instTypes.add(type);
    }

    return instTypes;
}

From source file:com.orange.clara.cloud.servicedbdumper.controllers.InterfaceControllerTest.java

@Before
public void setup() throws Exception {
    this.mockMvc = webAppContextSetup(webApplicationContext).build();
    Iterable<DbDumperPlan> dbDumperPlans = dbDumperPlanRepo.findAll();
    DbDumperPlan dbDumperPlan = dbDumperPlans.iterator().next();
    serviceInstance1 = new DbDumperServiceInstance(serviceId1, "plan-1", "org-1", "space-1",
            "http://dashboard.com", dbDumperPlan);
    serviceInstance2 = new DbDumperServiceInstance(serviceId2, "plan-2", "org-2", "space-2",
            "http://dashboard.com", dbDumperPlan);
    DatabaseRef databaseRef1 = new DatabaseRef(databaseName1, URI.create("mysql://foo:bar@mymysql-1/mydb"));
    DatabaseRef databaseRef2 = new DatabaseRef(databaseName2, URI.create("mysql://foo:bar@mymysql-2/mydb"));
    databaseRefRepo.save(Arrays.asList(databaseRef1, databaseRef2));
    serviceInstance1.setDatabaseRef(databaseRef1);
    serviceInstance2.setDatabaseRef(databaseRef2);
    instanceRepository.save(Arrays.asList(serviceInstance1, serviceInstance2));
}

From source file:edu.indiana.d2i.htrc.util.DataCopyValidation.java

@Override
public int run(String[] args) throws Exception {
    Configuration conf = getConf();

    String outputPath = args[0]; // result
    String dataAPIConfClassName = args[1];
    int maxIdsPerReq = Integer.valueOf(args[2]);

    logger.info("DataValidation ");
    logger.info(" - output: " + outputPath);
    logger.info(" - dataAPIConfClassName: " + dataAPIConfClassName);
    logger.info(" - maxIdsPerReq: " + maxIdsPerReq);

    Utilities.setDataAPIConf(conf, dataAPIConfClassName, maxIdsPerReq);

    //      HTRCDataAPIClient client = Utilities.creatDataAPIClient(conf);
    String dataEPR = conf.get(HTRCConstants.HOSTS_SEPARATEDBY_COMMA,
            "https://129-79-49-119.dhcp-bl.indiana.edu:25443/data-api");
    String delimitor = conf.get(HTRCConstants.DATA_API_URL_DELIMITOR, "|");
    String clientID = conf.get(HTRCConstants.DATA_API_CLIENTID, "yim");
    String clientSecrete = conf.get(HTRCConstants.DATA_API_CLIENTSECRETE, "yim");
    String tokenLoc = conf.get(HTRCConstants.DATA_API_TOKENLOC,
            "https://129-79-49-119.dhcp-bl.indiana.edu:25443/oauth2/token?grant_type=client_credentials");
    boolean selfsigned = conf.getBoolean(HTRCConstants.DATA_API_SELFSIGNED, true);
    HTRCDataAPIClient client = new HTRCDataAPIClient.Builder(dataEPR, delimitor).authentication(true)
            .selfsigned(selfsigned).clientID(clientID).clientSecrete(clientSecrete).tokenLocation(tokenLoc)
            .build();//from w  ww .ja va 2  s  .  c o  m

    FileSystem fs = FileSystem.get(conf);
    FileStatus[] status = fs.listStatus(new Path(outputPath), Utilities.HIDDEN_FILE_FILTER);
    Text key = new Text();
    Text value = new Text();
    for (int i = 0; i < status.length; i++) {
        SequenceFile.Reader seqReader = new SequenceFile.Reader(fs, status[i].getPath(), conf);
        while (seqReader.next(key, value)) {
            //            logger.info(key.toString());
            Iterable<Entry<String, String>> content = client.getID2Content(key.toString());
            Iterator<Entry<String, String>> iterator = content.iterator();
            Entry<String, String> entry = iterator.next();
            if (!entry.getValue().equals(value.toString())) {
                logger.error("Book : " + key.toString() + " corrupts!");
            }
        }
    }

    logger.info("Finish validation.");

    return 0;
}