当前位置: 首页>>代码示例>>Java>>正文


Java IteratorUtils.toList方法代码示例

本文整理汇总了Java中org.apache.commons.collections.IteratorUtils.toList方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtils.toList方法的具体用法?Java IteratorUtils.toList怎么用?Java IteratorUtils.toList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections.IteratorUtils的用法示例。


在下文中一共展示了IteratorUtils.toList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRemovalOfCommentsProperSplittingOfStatementsAndTrimmingOfEachOfIt

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testRemovalOfCommentsProperSplittingOfStatementsAndTrimmingOfEachOfIt() {
    // GIVEN
    final SqlScript script = new SqlScript(TEST_SCRIPT);

    // WHEN
    final List<String> list = IteratorUtils.toList(script.iterator());

    // THEN
    assertThat(list.size(), equalTo(12));
    assertThat(list, everyItem(not(containsString("comment"))));
    assertThat(list, everyItem(not(startsWith(" "))));
    assertThat(list, everyItem(not(startsWith("\t"))));
    assertThat(list, everyItem(not(endsWith(" "))));
    assertThat(list, everyItem(not(endsWith("\t"))));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:18,代码来源:SqlScriptTest.java

示例2: removeSubnet

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Override
public void removeSubnet(final String providerSubnetId) throws CloudException, InternalException {
    List<DataCenter> dataCenters = new ArrayList(IteratorUtils.toList(this.provider.getDataCenterServices().listDataCenters(this.provider.getContext().getRegionId()).iterator()));
    String dataCenterId = dataCenters.get(0).getProviderDataCenterId();

    WAPSubnetsModel subnetsModel = new AzurePackRequester(provider, new AzurePackNetworkRequests(provider).listSubnets(dataCenterId).build()).withJsonProcessor(WAPSubnetsModel.class).execute();

    WAPSubnetModel foundSubnetModel = (WAPSubnetModel)CollectionUtils.find(subnetsModel.getSubnets(), new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            return ((WAPSubnetModel) object).getId().equalsIgnoreCase(providerSubnetId);
        }
    });

    if(foundSubnetModel == null)
        throw new InternalException("Invalid subnet providerSubnetId provided");

    new AzurePackRequester(provider, new AzurePackNetworkRequests(provider).deleteSubnet(foundSubnetModel).build()).execute();
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:20,代码来源:AzurePackNetworkSupport.java

示例3: listAllProductsShouldReturnCorrectHardwareProfileProducts

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Test
public void listAllProductsShouldReturnCorrectHardwareProfileProducts() throws CloudException, InternalException {
    new ListProductsRequestExecutorMockUp();
    List<VirtualMachineProduct> products = IteratorUtils
            .toList(azurePackVirtualMachineSupport.listAllProducts().iterator());

    //listAllProducts returns all available hardware profile plus default product
    assertEquals("listProducts doesn't return correct result", 2, products.size());
    VirtualMachineProduct virtualMachineProduct = products.get(0);
    assertEquals("listProducts doesn't return correct result", HWP_1_NAME, virtualMachineProduct.getName());
    assertEquals("listProducts doesn't return correct result", HWP_1_ID, virtualMachineProduct.getProviderProductId());
    assertEquals("listProducts doesn't return correct result", Integer.parseInt(HWP_1_CPU_COUNT), virtualMachineProduct.getCpuCount());
    assertEquals("listProducts doesn't return correct result", Double.parseDouble(HWP_1_MEMORY), virtualMachineProduct.getRamSize().getQuantity());
    assertEquals("listProducts doesn't return correct result", Storage.MEGABYTE,
            virtualMachineProduct.getRamSize().getUnitOfMeasure());

    //assert default product
    virtualMachineProduct = products.get(1);
    assertEquals("listProducts doesn't return correct result", "default", virtualMachineProduct.getName().toLowerCase());
    assertEquals("listProducts doesn't return correct result", "default", virtualMachineProduct.getProviderProductId().toLowerCase());
    assertEquals("listProducts doesn't return correct result", "default", virtualMachineProduct.getDescription().toLowerCase());

}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:24,代码来源:AzurePackVirtualMachineSupportTest.java

示例4: searchImagesShouldReturnCorrectResult

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Test
public void searchImagesShouldReturnCorrectResult() throws CloudException, InternalException {
    new GetAllImagesRequestExecutorMockUp();
    List<MachineImage> images;
    images = IteratorUtils.toList(azurePackImageSupport.searchImages(null, null, null, null).iterator());
    assertEquals("searchImages doesn't return correct result", 6, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, null, null).iterator());
    assertEquals("searchImages doesn't return correct result", 2, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, Platform.WINDOWS, null).iterator());
    assertEquals("searchImages doesn't return correct result", 2, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, Platform.WINDOWS, null,
            ImageClass.MACHINE).iterator());
    assertEquals("searchImages doesn't return correct result", 2, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, Platform.WINDOWS, null,
            ImageClass.KERNEL).iterator());
    assertEquals("searchImages doesn't return correct result", 0, images.size());
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:22,代码来源:AzurePackImageSupportTest.java

示例5: checkExpiryDates

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Scheduled(cron = "0 0 5 * * *")
//@Scheduled(fixedDelay = 50000)
public void checkExpiryDates () {
    logger.info("checking expiry date..." + systemProperties.getProperty(SystemProperties.SysProps.EXPIRATION_BUFFER));
    int buffer = Integer.parseInt(systemProperties.getProperty(SystemProperties.SysProps.EXPIRATION_BUFFER));
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.DATE, (calendar.get(Calendar.DATE) - buffer));
    List<Vehicle> vehicles = IteratorUtils.toList(vehicleMongoDAO.findExpiring(calendar.getTime()).iterator());
    if (!vehicles.isEmpty()) {
        Map<String, Object> context = new HashMap<>();
        context.put("permitExpiring", vehicles.stream().filter(v -> v.getPermitExpiry().isBefore(calendar.getTime().getTime())).collect(Collectors.toList()));
        context.put("fitnessExpiring", vehicles.stream().filter(v -> v.getFitnessExpiry().isBefore(calendar.getTime().getTime())).collect(Collectors.toList()));
        context.put("authExpiring", vehicles.stream().filter(v -> v.getAuthExpiry().isBefore(calendar.getTime().getTime())).collect(Collectors.toList()));
        context.put("pollutionExpiring", vehicles.stream().filter(v -> v.getPollutionExpiry().isBefore(calendar.getTime().getTime())).collect(Collectors.toList()));
        context.put("insuranceExpiring", vehicles.stream().filter(v -> v.getInsuranceExpiry().isBefore(calendar.getTime().getTime())).collect(Collectors.toList()));
        String content = velocityEngineService.trasnform(context, VelocityEngineService.EXPIRING_DOCUMENTS_TEMPLATE);
        logger.info("Sending email for notifying expiring documents ...");
        emailSender.sendExpiringNotifications(content);
    }
}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:21,代码来源:SchedulerService.java

示例6: testSaveRouteWithNewName

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Test
public void testSaveRouteWithNewName() {
    Route savedRoute = routeManager.saveRoute(routeTestService.createTestRoute());
    //try saving the route with same name
    savedRoute.setId(null);
    //change the name and it should be good
    savedRoute.setName(savedRoute.getName() + "_New");
    routeManager.saveRoute(savedRoute);
    List<Route> routes = IteratorUtils.toList(routeDAO.findAll().iterator());
    Assert.assertEquals(2, routes.size());
    List cities =IteratorUtils.toList(cityDAO.findAll().iterator());
    Assert.assertEquals(2, cities.size());
    List activeRoutes = IteratorUtils.toList(routeDAO.findByActive(true).iterator());
    Assert.assertEquals(2, activeRoutes.size());
    List inActiveRoutes = IteratorUtils.toList(routeDAO.findByActive(false).iterator());
    Assert.assertEquals(0, inActiveRoutes.size());
}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:18,代码来源:RouteManagerTest.java

示例7: getBalanceRecordCount

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
/**
 * This method finds the summary records of balance entries according to input fields and values
 *
 * @param fieldValues the input fields and values
 * @param isConsolidated consolidation option is applied or not
 * @return the summary records of balance entries
 * @see org.kuali.kfs.gl.service.BalanceService#getBalanceRecordCount(java.util.Map, boolean)
 */
@Override
public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated) {
    LOG.debug("getBalanceRecordCount() started");

    Integer recordCount = null;
    if (!isConsolidated) {
        recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new Balance()).intValue();
    }
    else {
        Iterator recordCountIterator = balanceDao.getConsolidatedBalanceRecordCount(fieldValues, getEncumbranceBalanceTypes(fieldValues));
        // TODO: WL: why build a list and waste time/memory when we can just iterate through the iterator and do a count?
        List recordCountList = IteratorUtils.toList(recordCountIterator);
        recordCount = recordCountList.size();
    }
    return recordCount;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:25,代码来源:BalanceServiceImpl.java

示例8: testUpdatemanagingRole

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Test
public void testUpdatemanagingRole() throws Exception {
    JSONObject role = new JSONObject();
    role.put("name", "test");
    ResultActions actions = mockMvc.perform(asUser(post("/api/v1/createRole")
            .content(getObjectMapper().writeValueAsBytes(role))
            .contentType(MediaType.APPLICATION_JSON), currentUser));
            actions.andExpect(status().isOk());
    role.put("name", "test1");
    String menus = "['home','Menu','Partner']";
    role.put("menus", menus);
    mockMvc.perform(asUser(put(format("/api/v1/manageingrole/%s", role.get("id")))
            .content(getObjectMapper().writeValueAsBytes(role))
            .contentType(MediaType.APPLICATION_JSON), currentUser));
    List<Role> roles = IteratorUtils.toList(roleDAO.findAll().iterator());
    Assert.assertEquals(1,roles.size());
    Assert.assertEquals("test1", role.get("name"));
}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:19,代码来源:RoleControllerTest.java

示例9: getLayoutNames

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
/**
 * Module to build a map of <layoutId, layoutName>,
 * @param allLayouts -- when true all the names will be returned, when false only active layout names are returned
 * @return
 */
public Map<String, String> getLayoutNames(boolean allLayouts) {
    List<Layout> layouts = null;
    if(allLayouts) {
    	layouts = IteratorUtils.toList(layoutDAO.findAll().iterator());
    } else {
        //find only active cities
    	layouts = IteratorUtils.toList(layoutDAO.findByActive(true).iterator());
    }
    if (layouts == null || layouts.isEmpty() ) {
        return new HashMap<>();
    }
    Map<String, String> map = layouts.stream().collect(
            Collectors.toMap(Layout::getId, layout -> layout.getName()));
    return map;
}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:21,代码来源:LayoutManager.java

示例10: readAllOrganisations

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Override
public List<IOrganisation> readAllOrganisations(IUser actor) throws ServiceOrganisationExceptionNotAllowed,
        ServiceOrganisationExceptionNotFound {
    if (!actor.isAdmin()) {
        return readOrganisationsOwnedByUser(actor, actor.getId());
    }
    return IteratorUtils.toList(repositoryOrganisation.findAll().iterator());
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:9,代码来源:ServiceOrganisationImplRepository.java

示例11: readAllGroups

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Override
public List<IGroup> readAllGroups(final IUser actor) throws ServiceGroupExceptionNotAllowed {
    if (!actor.isAdmin()) {
        throw new ServiceGroupExceptionNotAllowed("Only administrators can read all groups");
    }
    return IteratorUtils.toList(this.repositoryGroup.findAll().iterator());
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:8,代码来源:ServiceGroupImplRepository.java

示例12: call

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<InventoryManifest.Locator> call(Iterator<InventoryReportLine> inventoryReport) throws IOException {
    // Exclude the empty iterators which are caused by the mapPartitions
    // when one partition only owns empty InventoryReportLine iterator after the filtering
    if (!inventoryReport.hasNext()){
        return Collections.emptyIterator();
    }
    List<InventoryReportLine> inventoryReportLineList = IteratorUtils.toList(inventoryReport);
    InventoryReportLineWriter scvWriter = new InventoryReportLineWriter(s3ClientFactory.getValue().get(),
            destBucket, destPrefix, srcBucket, manifestStorage);
    return Collections.singletonList(scvWriter.writeCsvFile(inventoryReportLineList)).iterator();
}
 
开发者ID:awslabs,项目名称:s3-inventory-usage-examples,代码行数:13,代码来源:WriteNewInventoryReportFunc.java

示例13: getDailySnapshot

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@GET
@Path("/dailysnapshot/{day}")
public Response getDailySnapshot(@PathParam("day")
                                 @NotNull String day) {

  OperationStats opStats = new OperationStats("cmdb_api", "get_dailysnapshot", new HashMap<>());
  Map<String, String> tags = new HashMap<>();

  try {
    DateTime time = DateTime.parse(day, DateTimeFormat.forPattern("yyyy-MM-dd"));
    DailySnapshotStore dailySnapshot = factory.getDailyStore(time);

    Iterator<EsDailySnapshotInstance>
        iter = dailySnapshot.getSnapshotInstances();
    List<EsDailySnapshotInstance> ret = IteratorUtils.toList(iter);

    logger.info("Success: getDailySnapshot - {}", day);
    return Response.status(Response.Status.OK)
        .type(MediaType.APPLICATION_JSON)
        .entity(ret)
        .build();

  } catch (Exception e) {

    return Utils.responseException(e, logger, opStats, tags);
  }

}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:29,代码来源:DailySnapshot.java

示例14: testBerkleyNgrams

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testBerkleyNgrams() throws Exception {
	LOG.debug("-- testNgrams --");
	
	BerkeleyLM<String> language_model = (BerkeleyLM<String>)LanguageModelHelper.createBerkelyLmFromTxtFilesInDirectory(new BreakIteratorStringProvider(), _testresources_folder, MAX_NGRAM_ORDER, -10f, -1, 1, false);

	List<List<String>> ngrams = IteratorUtils.toList(language_model.getNgramIterator());
	System.out.println(ngrams);
	assertEquals(false, ngrams.retainAll(tri_grams));

}
 
开发者ID:tudarmstadt-lt,项目名称:topicrawler,代码行数:13,代码来源:LanguageModelTest.java

示例15: generateMateriJasperReport

import org.apache.commons.collections.IteratorUtils; //导入方法依赖的package包/类
private JasperPrint generateMateriJasperReport() throws JRException, IOException {
    Map<String, Object> reportParameters = new HashMap<>();
    reportParameters.put("tanggalCetak", new Date());
    JRBeanCollectionDataSource reportData 
            = new JRBeanCollectionDataSource(IteratorUtils.toList(md.findAll().iterator()));
    JasperPrint materiReport = JasperFillManager.fillReport(getMateriJasper(), reportParameters, 
            reportData);
    return materiReport;
}
 
开发者ID:endymuhardin,项目名称:training-brainmatics-2016-01,代码行数:10,代码来源:MateriController.java


注:本文中的org.apache.commons.collections.IteratorUtils.toList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。