Search in sources :

Example 21 with Collections.singletonList

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);
}
Also used : ExpectedTask(com.evolveum.midpoint.wf.impl.ExpectedTask) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ExpectedWorkItem(com.evolveum.midpoint.wf.impl.ExpectedWorkItem) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) ApprovalInstruction(com.evolveum.midpoint.wf.impl.ApprovalInstruction) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ExpectedTask(com.evolveum.midpoint.wf.impl.ExpectedTask)

Example 22 with Collections.singletonList

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);
}
Also used : VisorIdleVerifyTaskArg(org.apache.ignite.internal.visor.verify.VisorIdleVerifyTaskArg) Random(java.util.Random) PartitionKeyV2(org.apache.ignite.internal.processors.cache.verify.PartitionKeyV2) IgniteEx(org.apache.ignite.internal.IgniteEx) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ArrayList(java.util.ArrayList) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 23 with Collections.singletonList

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);
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) ArrayList(java.util.ArrayList) OFGroupDescStatsReply(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) TransportPort(org.projectfloodlight.openflow.types.TransportPort) OFGroupDescStatsRequest(org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest)

Aggregations

Collections.singletonList (java.util.Collections.singletonList)23 List (java.util.List)23 ArrayList (java.util.ArrayList)19 Collections.emptyList (java.util.Collections.emptyList)12 Test (org.junit.jupiter.api.Test)12 Arrays.asList (java.util.Arrays.asList)9 TopicPartition (org.apache.kafka.common.TopicPartition)9 ByteBuffer (java.nio.ByteBuffer)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)7 Map (java.util.Map)6 Node (org.apache.kafka.common.Node)6 Cluster (org.apache.kafka.common.Cluster)5 PartitionInfo (org.apache.kafka.common.PartitionInfo)5 FetchResponseData (org.apache.kafka.common.message.FetchResponseData)4 SimpleRecord (org.apache.kafka.common.record.SimpleRecord)4 Collection (java.util.Collection)3 Collections (java.util.Collections)3 Collections.emptySet (java.util.Collections.emptySet)3 Collections.singleton (java.util.Collections.singleton)3