use of java.util.Collections.singletonList in project midpoint by Evolveum.
the class AbstractTestObjectLifecycleApproval method createObject.
private void createObject(ObjectType object, boolean immediate, boolean approve, String assigneeOid) throws Exception {
// noinspection unchecked
ObjectDelta<RoleType> addObjectDelta = DeltaFactory.Object.createAddDelta((PrismObject<RoleType>) object.asPrismObject());
executeTest(new TestDetails() {
@Override
protected LensContext createModelContext(OperationResult result) throws Exception {
// noinspection unchecked
LensContext<RoleType> lensContext = createLensContext((Class) object.getClass());
addFocusDeltaToContext(lensContext, addObjectDelta);
return lensContext;
}
@Override
protected void afterFirstClockworkRun(CaseType rootCase, CaseType case0, List<CaseType> subcases, List<CaseWorkItemType> workItems, Task opTask, OperationResult result) throws Exception {
if (!immediate) {
// ModelContext taskModelContext = temporaryHelper.getModelContext(rootCase, opTask, result);
// ObjectDelta realDelta0 = taskModelContext.getFocusContext().getPrimaryDelta();
// assertTrue("Non-empty primary focus delta: " + realDelta0.debugDump(), realDelta0.isEmpty());
assertNoObject(object);
ExpectedTask expectedTask = new ExpectedTask(null, "Adding role \"" + object.getName().getOrig() + "\"");
ExpectedWorkItem expectedWorkItem = new ExpectedWorkItem(assigneeOid, null, expectedTask);
assertWfContextAfterClockworkRun(rootCase, subcases, workItems, null, Collections.singletonList(expectedTask), Collections.singletonList(expectedWorkItem));
}
}
@Override
protected void afterCase0Finishes(CaseType rootCase, Task opTask, OperationResult result) throws Exception {
assertNoObject(object);
}
@Override
protected void afterRootCaseFinishes(CaseType rootCase, List<CaseType> subcases, Task opTask, OperationResult result) throws Exception {
if (approve) {
assertObject(object);
} else {
assertNoObject(object);
}
}
@Override
protected boolean executeImmediately() {
return immediate;
}
@Override
public List<ApprovalInstruction> getApprovalSequence() {
return singletonList(new ApprovalInstruction(null, true, USER_JUPITER_OID, "creation comment"));
}
}, 1);
}
use of java.util.Collections.singletonList in project ignite by apache.
the class IgniteClusterSnapshotCheckTest method testClusterSnapshotCheckHashesSameAsIdleVerifyHashes.
/**
* @throws Exception If fails.
*/
@Test
public void testClusterSnapshotCheckHashesSameAsIdleVerifyHashes() throws Exception {
Random rnd = new Random();
CacheConfiguration<Integer, Value> ccfg = txCacheConfig(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
IgniteEx ignite = startGridsWithCache(1, CACHE_KEYS_RANGE, k -> new Value(new byte[rnd.nextInt(32768)]), ccfg);
ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
IdleVerifyResultV2 idleVerifyRes = ignite.compute().execute(new TestVisorBackupPartitionsTask(), new VisorIdleVerifyTaskArg(new HashSet<>(singletonList(ccfg.getName())), new HashSet<>(), false, CacheFilterEnum.USER, true));
IdleVerifyResultV2 snpVerifyRes = ignite.compute().execute(new TestSnapshotPartitionsVerifyTask(), new SnapshotPartitionsVerifyTaskArg(new HashSet<>(), Collections.singletonMap(ignite.cluster().localNode(), Collections.singletonList(snp(ignite).readSnapshotMetadata(SNAPSHOT_NAME, (String) ignite.configuration().getConsistentId()))))).idleVerifyResult();
Map<PartitionKeyV2, List<PartitionHashRecordV2>> idleVerifyHashes = jobResults.get(TestVisorBackupPartitionsTask.class);
Map<PartitionKeyV2, List<PartitionHashRecordV2>> snpCheckHashes = jobResults.get(TestVisorBackupPartitionsTask.class);
assertFalse(F.isEmpty(idleVerifyHashes));
assertFalse(F.isEmpty(snpCheckHashes));
assertEquals(idleVerifyHashes, snpCheckHashes);
assertEquals(idleVerifyRes, snpVerifyRes);
}
use of java.util.Collections.singletonList in project open-kilda by telstra.
the class SwitchManagerTest method mockGetGroupsRequest.
private void mockGetGroupsRequest(List<Integer> groupIds) throws Exception {
List<OFGroupDescStatsEntry> meterConfigs = new ArrayList<>(groupIds.size());
for (Integer groupId : groupIds) {
OFBucket firstBucket = mock(OFBucket.class);
OFBucket secondBucket = mock(OFBucket.class);
OFActionSetField setDestMacAction = ofFactory.actions().buildSetField().setField(ofFactory.oxms().buildEthDst().setValue(convertDpIdToMac(dpid)).build()).build();
OFActionOutput sendToControllerAction = ofFactory.actions().output(OFPort.CONTROLLER, 0xFFFFFFFF);
TransportPort udpPort = TransportPort.of(LATENCY_PACKET_UDP_PORT);
OFActionSetField setUdpDstAction = ofFactory.actions().setField(ofFactory.oxms().udpDst(udpPort));
OFActionOutput sendInPortAction = ofFactory.actions().output(OFPort.IN_PORT, 0xFFFFFFFF);
expect(firstBucket.getActions()).andStubReturn(Lists.newArrayList(setDestMacAction, sendToControllerAction));
expect(secondBucket.getActions()).andStubReturn(Lists.newArrayList(setUdpDstAction, sendInPortAction));
OFGroupDescStatsEntry groupEntry = mock(OFGroupDescStatsEntry.class);
expect(groupEntry.getGroup()).andStubReturn(OFGroup.of(groupId));
expect(groupEntry.getBuckets()).andStubReturn(Lists.newArrayList(firstBucket, secondBucket));
replay(firstBucket, secondBucket, groupEntry);
meterConfigs.add(groupEntry);
}
OFGroupDescStatsReply statsReply = mock(OFGroupDescStatsReply.class);
expect(statsReply.getEntries()).andStubReturn(meterConfigs);
ListenableFuture<List<OFGroupDescStatsReply>> ofStatsFuture = mock(ListenableFuture.class);
expect(ofStatsFuture.get(anyLong(), anyObject())).andStubReturn(Collections.singletonList(statsReply));
expect(iofSwitch.writeStatsRequest(isA(OFGroupDescStatsRequest.class))).andStubReturn(ofStatsFuture);
replay(statsReply, ofStatsFuture);
}
Aggregations