@Test public void testToAndFromPb() { compareLogOperation(OPERATION, Operation.fromPb(OPERATION.toPb())); Operation operation = Operation.of(ID, PRODUCER); compareLogOperation(operation, Operation.fromPb(operation.toPb())); }
@Test public void testOf() { Operation operation = Operation.of(ID, PRODUCER); assertEquals(ID, operation.getId()); assertEquals(PRODUCER, operation.getProducer()); assertFalse(operation.first()); assertFalse(operation.last()); }
.addLabel("key2", "value2") .setLogName(logId) .setOperation(Operation.of("operationId", "operationProducer")) .setResource(MonitoredResource.newBuilder("cloudsql_database").build()) .build(); assertEquals(ImmutableMap.of("key2", "value2"), entry.getLabels()); assertEquals("cloudsql_database", entry.getResource().getType()); assertEquals(Operation.of("operationId", "operationProducer"), entry.getOperation()); assertEquals(Severity.DEFAULT, entry.getSeverity()); assertNull(entry.getHttpRequest());
.clearLabels() .addLabel("key", "value") .setOperation(Operation.of("otherId", "otherProducer")) .setTrace("otherTrace") .setSpanId("otherSpanId") assertEquals(request, logEntry.getHttpRequest()); assertEquals(ImmutableMap.of("key", "value"), logEntry.getLabels()); assertEquals(Operation.of("otherId", "otherProducer"), logEntry.getOperation()); assertEquals("otherTrace", logEntry.getTrace()); assertEquals("otherSpanId", logEntry.getSpanId());