use of com.google.common.collect.Lists.newArrayList in project guava by google.
the class IteratorTesterTest method testVerifyCanThrowAssertionThatFailsTest.
public void testVerifyCanThrowAssertionThatFailsTest() {
final String message = "Important info about why verify failed";
IteratorTester<Integer> tester = new IteratorTester<Integer>(1, MODIFIABLE, newArrayList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<Integer> newTargetIterator() {
return Lists.newArrayList(1, 2, 3).iterator();
}
@Override
protected void verify(List<Integer> elements) {
throw new AssertionFailedError(message);
}
};
AssertionFailedError actual = null;
try {
tester.test();
} catch (AssertionFailedError e) {
actual = e;
}
assertNotNull("verify() should be able to cause test failure", actual);
assertTrue("AssertionFailedError should have info about why test failed", actual.getCause().getMessage().contains(message));
}
use of com.google.common.collect.Lists.newArrayList in project jackrabbit-oak by apache.
the class Oak method createNewContentRepository.
private ContentRepository createNewContentRepository() {
final RepoStateCheckHook repoStateCheckHook = new RepoStateCheckHook();
final List<Registration> regs = Lists.newArrayList();
regs.add(whiteboard.register(Executor.class, getExecutor(), Collections.emptyMap()));
IndexEditorProvider indexEditors = CompositeIndexEditorProvider.compose(indexEditorProviders);
OakInitializer.initialize(store, new CompositeInitializer(initializers), indexEditors);
QueryIndexProvider indexProvider = CompositeQueryIndexProvider.compose(queryIndexProviders);
commitHooks.add(repoStateCheckHook);
List<CommitHook> initHooks = new ArrayList<CommitHook>(commitHooks);
initHooks.add(new EditorHook(CompositeEditorProvider.compose(editorProviders)));
if (asyncTasks != null) {
IndexMBeanRegistration indexRegistration = new IndexMBeanRegistration(whiteboard);
regs.add(indexRegistration);
for (Entry<String, Long> t : asyncTasks.entrySet()) {
AsyncIndexUpdate task = new AsyncIndexUpdate(t.getKey(), store, indexEditors);
indexRegistration.registerAsyncIndexer(task, t.getValue());
closer.register(task);
}
PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(new AsyncIndexUpdate(IndexConstants.ASYNC_REINDEX_VALUE, store, indexEditors, true), getExecutor());
regs.add(registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async"));
}
regs.add(registerMBean(whiteboard, NodeCounterMBean.class, new NodeCounter(store), NodeCounterMBean.TYPE, "nodeCounter"));
regs.add(registerMBean(whiteboard, QueryEngineSettingsMBean.class, queryEngineSettings, QueryEngineSettingsMBean.TYPE, "settings"));
// FIXME: OAK-810 move to proper workspace initialization
// initialize default workspace
Iterable<WorkspaceInitializer> workspaceInitializers = Iterables.transform(securityProvider.getConfigurations(), new Function<SecurityConfiguration, WorkspaceInitializer>() {
@Override
public WorkspaceInitializer apply(SecurityConfiguration sc) {
return sc.getWorkspaceInitializer();
}
});
OakInitializer.initialize(workspaceInitializers, store, defaultWorkspaceName, indexEditors);
// add index hooks later to prevent the OakInitializer to do excessive indexing
with(new IndexUpdateProvider(indexEditors, failOnMissingIndexProvider));
withEditorHook();
// Register observer last to prevent sending events while initialising
for (Observer observer : observers) {
regs.add(whiteboard.register(Observer.class, observer, emptyMap()));
}
RepositoryManager repositoryManager = new RepositoryManager(whiteboard);
regs.add(registerMBean(whiteboard, RepositoryManagementMBean.class, repositoryManager, RepositoryManagementMBean.TYPE, repositoryManager.getName()));
CommitHook composite = CompositeHook.compose(commitHooks);
regs.add(whiteboard.register(CommitHook.class, composite, Collections.emptyMap()));
final Tracker<Descriptors> t = whiteboard.track(Descriptors.class);
return new ContentRepositoryImpl(store, composite, defaultWorkspaceName, queryEngineSettings.unwrap(), indexProvider, securityProvider, new AggregatingDescriptors(t)) {
@Override
public void close() throws IOException {
super.close();
repoStateCheckHook.close();
new CompositeRegistration(regs).unregister();
closer.close();
}
};
}
use of com.google.common.collect.Lists.newArrayList in project dhis2-core by dhis2.
the class DataApprovalController method getApproval.
@RequestMapping(value = STATUS_PATH, method = RequestMethod.GET, produces = ContextUtils.CONTENT_TYPE_JSON)
@ResponseBody
public RootNode getApproval(@RequestParam Set<String> ds, @RequestParam(required = false) String pe, @RequestParam Date startDate, @RequestParam Date endDate, @RequestParam Set<String> ou, @RequestParam(required = false) boolean children, HttpServletResponse response) throws IOException, WebMessageException {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
List<String> defaults = new ArrayList<>();
defaults.add("period[id,name,code],organisationUnit[id,name,created,lastUpdated],dataSet[code,name,created,lastUpdated,id]");
fields.addAll(defaults);
}
Set<DataSet> dataSets = parseDataSetsWithWorkflow(ds);
Set<Period> periods = new HashSet<>();
PeriodType periodType = periodService.getPeriodTypeByName(pe);
if (periodType != null) {
periods.addAll(periodService.getPeriodsBetweenDates(periodType, startDate, endDate));
} else {
periods.addAll(periodService.getPeriodsBetweenDates(startDate, endDate));
}
Set<OrganisationUnit> organisationUnits = new HashSet<>();
if (children) {
organisationUnits.addAll(organisationUnitService.getOrganisationUnitsWithChildren(ou));
} else {
organisationUnits.addAll(organisationUnitService.getOrganisationUnitsByUid(ou));
}
DataApprovalStateResponses dataApprovalStateResponses = new DataApprovalStateResponses();
for (DataSet dataSet : dataSets) {
for (OrganisationUnit organisationUnit : organisationUnits) {
for (Period period : periods) {
dataApprovalStateResponses.add(getDataApprovalStateResponse(dataSet, organisationUnit, period));
}
}
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
RootNode rootNode = NodeUtils.createMetadata();
rootNode.addChild(fieldFilterService.filter(DataApprovalStateResponse.class, dataApprovalStateResponses.getDataApprovalStateResponses(), fields));
return rootNode;
}
Aggregations