use of java.util.Arrays.asList in project mongo-java-driver by mongodb.
the class CollectionAcceptanceTest method shouldAcceptDocumentsWithAllValidValueTypes.
@Test
public void shouldAcceptDocumentsWithAllValidValueTypes() {
Document doc = new Document();
doc.append("_id", new ObjectId());
doc.append("bool", true);
doc.append("int", 3);
doc.append("long", 5L);
doc.append("str", "Hello MongoDB");
doc.append("double", 1.1);
doc.append("date", new Date());
doc.append("ts", new BsonTimestamp(5, 1));
doc.append("pattern", new BsonRegularExpression("abc"));
doc.append("minKey", new MinKey());
doc.append("maxKey", new MaxKey());
doc.append("js", new Code("code"));
doc.append("jsWithScope", new CodeWithScope("code", new Document()));
doc.append("null", null);
doc.append("binary", new Binary((byte) 42, new byte[] { 10, 11, 12 }));
doc.append("list", Arrays.asList(7, 8, 9));
doc.append("doc list", Arrays.asList(new Document("x", 1), new Document("x", 2)));
collection.insertOne(doc);
Document found = collection.find().first();
assertNotNull(found);
assertEquals(ObjectId.class, found.get("_id").getClass());
assertEquals(Boolean.class, found.get("bool").getClass());
assertEquals(Integer.class, found.get("int").getClass());
assertEquals(Long.class, found.get("long").getClass());
assertEquals(String.class, found.get("str").getClass());
assertEquals(Double.class, found.get("double").getClass());
assertEquals(Date.class, found.get("date").getClass());
assertEquals(BsonTimestamp.class, found.get("ts").getClass());
assertEquals(BsonRegularExpression.class, found.get("pattern").getClass());
assertEquals(MinKey.class, found.get("minKey").getClass());
assertEquals(MaxKey.class, found.get("maxKey").getClass());
assertEquals(Code.class, found.get("js").getClass());
assertEquals(CodeWithScope.class, found.get("jsWithScope").getClass());
assertNull(found.get("null"));
assertEquals(Binary.class, found.get("binary").getClass());
assertTrue(found.get("list") instanceof List);
assertTrue(found.get("doc list") instanceof List);
}
use of java.util.Arrays.asList in project coprhd-controller by CoprHD.
the class BlockDeviceController method expandVolume.
@Override
public void expandVolume(URI storage, URI pool, URI volume, Long size, String opId) throws ControllerException {
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
Volume volumeObj = _dbClient.queryObject(Volume.class, volume);
_log.info(String.format("expandVolume start - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, OldSize: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getCapacity(), size));
StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
VolumeExpandCompleter completer = new VolumeExpandCompleter(volume, size, opId);
long metaMemberSize = volumeObj.getIsComposite() ? volumeObj.getMetaMemberSize() : volumeObj.getCapacity();
long metaCapacity = volumeObj.getIsComposite() ? volumeObj.getTotalMetaMemberCapacity() : volumeObj.getCapacity();
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volumeObj.getVirtualPool());
boolean isThinlyProvisioned = volumeObj.getThinlyProvisioned();
MetaVolumeRecommendation recommendation = MetaVolumeUtils.getExpandRecommendation(storageObj, poolObj, metaCapacity, size, metaMemberSize, isThinlyProvisioned, vpool.getFastExpansion());
if (recommendation.isCreateMetaVolumes()) {
// Also check that this is not recovery to clean dangling meta volumes with zero-capacity expansion.
if (recommendation.getMetaMemberCount() == 0 && (volumeObj.getMetaVolumeMembers() == null || volumeObj.getMetaVolumeMembers().isEmpty())) {
volumeObj.setCapacity(size);
_dbClient.updateObject(volumeObj);
_log.info(String.format("Expanded volume within its total meta volume capacity (simple case) - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, Total meta volume capacity: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getTotalMetaMemberCapacity(), volumeObj.getCapacity()));
completer.ready(_dbClient);
} else {
// set meta related data in task completer
long metaMemberCount = volumeObj.getIsComposite() ? recommendation.getMetaMemberCount() + volumeObj.getMetaMemberCount() : recommendation.getMetaMemberCount() + 1;
completer.setMetaMemberSize(recommendation.getMetaMemberSize());
completer.setMetaMemberCount((int) metaMemberCount);
completer.setTotalMetaMembersSize(metaMemberCount * recommendation.getMetaMemberSize());
completer.setComposite(true);
completer.setMetaVolumeType(recommendation.getMetaVolumeType().toString());
getDevice(storageObj.getSystemType()).doExpandAsMetaVolume(storageObj, poolObj, volumeObj, size, recommendation, completer);
}
} else {
// expand as regular volume
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_080);
getDevice(storageObj.getSystemType()).doExpandVolume(storageObj, poolObj, volumeObj, size, completer);
}
_log.info(String.format("expandVolume end - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()));
} catch (Exception e) {
_log.error(String.format("expandVolume Failed - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()), e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
List<URI> volumes = Arrays.asList(volume);
doFailTask(Volume.class, volumes, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of java.util.Arrays.asList in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows.
@Test
public void testBuildSpreadSheetRows() throws ParseException, NoSuchFieldException {
Employee employee1 = filter.getEmployees().get(0);
Employee employee2 = filter.getEmployees().get(1);
Project project1 = filter.getProjects().get(0);
Project project2 = filter.getProjects().get(1);
HourType hourType1 = filter.getHourTypes().get(0);
HourType hourType2 = filter.getHourTypes().get(1);
List<Hours> hours = getHours();
expect(hoursRepository.getHours(filter)).andReturn(hours);
Map<Project, List<Project>> subprojects = createSubprojects();
expect(projectService.getHighlevelOnly(filter.getProjects())).andReturn(filter.getProjects());
expect(projectRepository.getSubprojectsMap(filter.getProjects())).andReturn(subprojects);
expect(workTimeService.getEmployees(filter)).andReturn(Arrays.asList(employee1, employee2)).anyTimes();
replay(hoursRepository, projectRepository, workTimeService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows(new Employee());
verify(hoursRepository, projectRepository);
assertEquals(15, actual.size());
// master project head
assertRowMatch(actual.get(0), project1, null, null, emptyList());
assertRowMatch(actual.get(1), project1, employee1, hourType1, findHours(hours, project1, employee1, hourType1));
assertRowMatch(actual.get(2), project1, employee1, hourType2, findHours(hours, project1, employee1, hourType2));
// master project total1
assertRowMatch(actual.get(3), project1, null, hourType1, emptyList());
// master project total2
assertRowMatch(actual.get(4), project1, null, hourType2, emptyList());
Project subproject = subprojects.get(project1).get(0);
// subproject head
assertRowMatch(actual.get(5), subproject, null, null, emptyList());
assertRowMatch(actual.get(6), subproject, employee1, hourType1, findHours(hours, subproject, employee1, hourType1));
// subproject total
assertRowMatch(actual.get(7), subproject, null, hourType1, emptyList());
// space row
assertRowMatch(actual.get(8), null, null, null, emptyList());
// master project total1
assertRowMatch(actual.get(9), project1, null, hourType1, emptyList());
// master project total2
assertRowMatch(actual.get(10), project1, null, hourType2, emptyList());
// project 2
assertRowMatch(actual.get(11), project2, null, null, emptyList());
assertRowMatch(actual.get(12), project2, employee1, hourType1, findHours(hours, project2, employee1, hourType1));
assertRowMatch(actual.get(13), project2, employee2, hourType1, findHours(hours, project2, employee2, hourType1));
assertRowMatch(actual.get(14), project2, null, hourType1, emptyList());
}
use of java.util.Arrays.asList in project drools by kiegroup.
the class FlowTest method testFromGlobal.
@Test
public void testFromGlobal() throws Exception {
// global java.util.List list
// rule R when
// $o : String(length > 3) from list
// then
// insert($o);
// end
final Global<List> var_list = globalOf(List.class, "defaultpkg", "list");
final Variable<String> var_$o = declarationOf(String.class, "$o", // cannot use Function.identity() here because target type is ?.
from(var_list, x -> x));
Rule rule = rule("R").build(expr("$expr$1$", var_$o, (_this) -> _this.length() > 3).indexedBy(int.class, org.drools.model.Index.ConstraintType.GREATER_THAN, 0, _this -> _this.length(), 3).reactOn("length"), on(var_$o).execute((drools, $o) -> {
drools.insert($o);
}));
Model model = new ModelImpl().addGlobal(var_list).addRule(rule);
KieBase kieBase = KieBaseBuilder.createKieBaseFromModel(model);
KieSession ksession = kieBase.newKieSession();
List<String> messages = Arrays.asList("a", "Hello World!", "b");
ksession.setGlobal("list", messages);
ksession.fireAllRules();
List<String> results = getObjectsIntoList(ksession, String.class);
assertFalse(results.contains("a"));
assertTrue(results.contains("Hello World!"));
assertFalse(results.contains("b"));
}
use of java.util.Arrays.asList in project n4js by eclipse.
the class GHOLD_101_WorkingSetsTest_PluginUITest method tearDown.
@Override
public void tearDown() throws Exception {
super.tearDown();
broker.resetState();
waitForIdleState();
final TreeItem[] treeItems = commonViewer.getTree().getItems();
assertTrue("Expected empty Project Explorer. Input was: " + Arrays.toString(treeItems), Arrays2.isEmpty(treeItems));
assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel());
assertNull("Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution());
IContributionItem showHiddenWorkingSetsItem = from(Arrays.asList(projectExplorer.getViewSite().getActionBars().getToolBarManager().getItems())).firstMatch(i -> ShowHiddenWorkingSetsDropDownAction.class.getName().equals(i.getId())).orNull();
assertNull("Show hidden working set drop down contribution was visible when projects are configured as top level elements.", showHiddenWorkingSetsItem);
}
Aggregations