本文整理汇总了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"))));
}
示例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();
}
示例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());
}
示例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());
}
示例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);
}
}
示例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());
}
示例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;
}
示例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"));
}
示例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;
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
}
示例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));
}
示例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;
}