Search in sources :

Example 6 with ReportWorkItemStatusRequest

use of com.google.api.services.dataflow.model.ReportWorkItemStatusRequest in project beam by apache.

the class CounterShortIdCacheTest method testCacheStructuredName.

@Test
public void testCacheStructuredName() {
    CounterShortIdCache shortIdCache = new CounterShortIdCache();
    ReportWorkItemStatusRequest request = new ReportWorkItemStatusRequest();
    ReportWorkItemStatusResponse reply = new ReportWorkItemStatusResponse();
    // setup mock counters, three work statuses, one with two counters, one with one, one with none
    request.setWorkItemStatuses(createWorkStatusStructuredName(new String[] { "counter", "counter1" }, new String[] {}, new String[] { "counter2" }));
    reply.setWorkItemServiceStates(createWorkServiceState(new Long[] { 1000L, 1001L }, new Long[] {}, new Long[] { 1002L }));
    // Verify the empty case
    WorkItemStatus status1 = request.getWorkItemStatuses().get(0);
    WorkItemStatus status2 = request.getWorkItemStatuses().get(1);
    WorkItemStatus status3 = request.getWorkItemStatuses().get(2);
    shortIdCache.shortenIdsIfAvailable(status1.getCounterUpdates());
    for (CounterUpdate update : status1.getCounterUpdates()) {
        assertNull(update.getShortId());
    }
    // Add the shortIds
    shortIdCache.storeNewShortIds(request, reply);
    shortIdCache.shortenIdsIfAvailable(status1.getCounterUpdates());
    shortIdCache.shortenIdsIfAvailable(status2.getCounterUpdates());
    shortIdCache.shortenIdsIfAvailable(status3.getCounterUpdates());
    checkStatusAndShortIds(status1, 1000L, 1001L);
    checkStatusAndShortIds(status2);
    checkStatusAndShortIds(status3, 1002L);
}
Also used : WorkItemStatus(com.google.api.services.dataflow.model.WorkItemStatus) ReportWorkItemStatusResponse(com.google.api.services.dataflow.model.ReportWorkItemStatusResponse) ReportWorkItemStatusRequest(com.google.api.services.dataflow.model.ReportWorkItemStatusRequest) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) Test(org.junit.Test)

Aggregations

ReportWorkItemStatusRequest (com.google.api.services.dataflow.model.ReportWorkItemStatusRequest)6 ReportWorkItemStatusResponse (com.google.api.services.dataflow.model.ReportWorkItemStatusResponse)6 Test (org.junit.Test)5 WorkItemStatus (com.google.api.services.dataflow.model.WorkItemStatus)3 CounterUpdate (com.google.api.services.dataflow.model.CounterUpdate)2 MetricShortId (com.google.api.services.dataflow.model.MetricShortId)2 WorkItemServiceState (com.google.api.services.dataflow.model.WorkItemServiceState)1 IOException (java.io.IOException)1 DateTime (org.joda.time.DateTime)1