Search in sources :

Example 6 with MachineStatusEvent

use of org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent in project devspaces-images by redhat-developer.

the class KubernetesInternalRuntimeTest method verifyOrderedEventsChains.

private void verifyOrderedEventsChains(MachineStatusEvent[]... eventsArrays) {
    Map<String, LinkedList<MachineStatusEvent>> machine2Events = new HashMap<>();
    List<MachineStatusEvent> machineStatusEvents = captureEvents();
    for (MachineStatusEvent event : machineStatusEvents) {
        final String machineName = event.getMachineName();
        machine2Events.computeIfPresent(machineName, (mName, events) -> {
            events.add(event);
            return events;
        });
        machine2Events.computeIfAbsent(machineName, mName -> {
            final LinkedList<MachineStatusEvent> events = new LinkedList<>();
            events.add(event);
            return events;
        });
    }
    for (MachineStatusEvent[] expected : eventsArrays) {
        final MachineStatusEvent machineStatusEvent = expected[0];
        final MachineStatusEvent[] actual = machine2Events.remove(machineStatusEvent.getMachineName()).toArray(new MachineStatusEvent[expected.length]);
        assertEquals(actual, expected);
    }
    assertTrue(machine2Events.isEmpty(), "No more events expected");
}
Also used : MachineStatusEvent(org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent) HashMap(java.util.HashMap) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) LinkedList(java.util.LinkedList)

Aggregations

MachineStatusEvent (org.eclipse.che.api.workspace.shared.dto.event.MachineStatusEvent)6 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)4 HashMap (java.util.HashMap)4 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)2 Container (io.fabric8.kubernetes.api.model.Container)2 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)2 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 IntOrStringBuilder (io.fabric8.kubernetes.api.model.IntOrStringBuilder)2 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)2 Secret (io.fabric8.kubernetes.api.model.Secret)2 Service (io.fabric8.kubernetes.api.model.Service)2 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)2 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)2