Search in sources :

Example 1 with Allocation

use of com.google.cloud.tools.jib.event.progress.Allocation in project jib by google.

the class ProgressEventTest method testSmoke.

@Test
public void testSmoke() {
    Consumer<ProgressEvent> progressEventConsumer = progressEvent -> {
        Allocation allocation = progressEvent.getAllocation();
        long units = progressEvent.getUnits();
        updateCompletionMap(allocation, units);
    };
    EventHandlers eventHandlers = makeEventHandlers(progressEventConsumer);
    eventHandlers.dispatch(new ProgressEvent(AllocationTree.child1Child, 50));
    Assert.assertEquals(1, allocationCompletionMap.size());
    Assert.assertEquals(50, allocationCompletionMap.get(AllocationTree.child1Child).longValue());
    eventHandlers.dispatch(new ProgressEvent(AllocationTree.child1Child, 50));
    Assert.assertEquals(3, allocationCompletionMap.size());
    Assert.assertEquals(100, allocationCompletionMap.get(AllocationTree.child1Child).longValue());
    Assert.assertEquals(1, allocationCompletionMap.get(AllocationTree.child1).longValue());
    Assert.assertEquals(1, allocationCompletionMap.get(AllocationTree.root).longValue());
    eventHandlers.dispatch(new ProgressEvent(AllocationTree.child2, 200));
    Assert.assertEquals(4, allocationCompletionMap.size());
    Assert.assertEquals(100, allocationCompletionMap.get(AllocationTree.child1Child).longValue());
    Assert.assertEquals(1, allocationCompletionMap.get(AllocationTree.child1).longValue());
    Assert.assertEquals(200, allocationCompletionMap.get(AllocationTree.child2).longValue());
    Assert.assertEquals(2, allocationCompletionMap.get(AllocationTree.root).longValue());
}
Also used : Consumer(java.util.function.Consumer) Allocation(com.google.cloud.tools.jib.event.progress.Allocation) Map(java.util.Map) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers) HashMap(java.util.HashMap) Test(org.junit.Test) Assert(org.junit.Assert) Allocation(com.google.cloud.tools.jib.event.progress.Allocation) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers) Test(org.junit.Test)

Example 2 with Allocation

use of com.google.cloud.tools.jib.event.progress.Allocation in project jib by GoogleContainerTools.

the class ProgressEventTest method testSmoke.

@Test
public void testSmoke() {
    Consumer<ProgressEvent> progressEventConsumer = progressEvent -> {
        Allocation allocation = progressEvent.getAllocation();
        long units = progressEvent.getUnits();
        updateCompletionMap(allocation, units);
    };
    EventHandlers eventHandlers = makeEventHandlers(progressEventConsumer);
    eventHandlers.dispatch(new ProgressEvent(AllocationTree.child1Child, 50));
    Assert.assertEquals(1, allocationCompletionMap.size());
    Assert.assertEquals(50, allocationCompletionMap.get(AllocationTree.child1Child).longValue());
    eventHandlers.dispatch(new ProgressEvent(AllocationTree.child1Child, 50));
    Assert.assertEquals(3, allocationCompletionMap.size());
    Assert.assertEquals(100, allocationCompletionMap.get(AllocationTree.child1Child).longValue());
    Assert.assertEquals(1, allocationCompletionMap.get(AllocationTree.child1).longValue());
    Assert.assertEquals(1, allocationCompletionMap.get(AllocationTree.root).longValue());
    eventHandlers.dispatch(new ProgressEvent(AllocationTree.child2, 200));
    Assert.assertEquals(4, allocationCompletionMap.size());
    Assert.assertEquals(100, allocationCompletionMap.get(AllocationTree.child1Child).longValue());
    Assert.assertEquals(1, allocationCompletionMap.get(AllocationTree.child1).longValue());
    Assert.assertEquals(200, allocationCompletionMap.get(AllocationTree.child2).longValue());
    Assert.assertEquals(2, allocationCompletionMap.get(AllocationTree.root).longValue());
}
Also used : Consumer(java.util.function.Consumer) Allocation(com.google.cloud.tools.jib.event.progress.Allocation) Map(java.util.Map) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers) HashMap(java.util.HashMap) Test(org.junit.Test) Assert(org.junit.Assert) Allocation(com.google.cloud.tools.jib.event.progress.Allocation) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers) Test(org.junit.Test)

Aggregations

EventHandlers (com.google.cloud.tools.jib.event.EventHandlers)2 Allocation (com.google.cloud.tools.jib.event.progress.Allocation)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Consumer (java.util.function.Consumer)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2