use of com.google.apphosting.api.logservice.LogServicePb.LogReadRequest in project appengine-java-standard by GoogleCloudPlatform.
the class LocalLogServiceTest method testHexRequestIdOffsetHandling.
@Test
public void testHexRequestIdOffsetHandling() {
LogOffset offset = LogOffset.newBuilder().setRequestId(ByteString.copyFromUtf8(String.format("%x", new BigInteger("12345")))).build();
LogReadRequest request = LogReadRequest.newBuilder().setAppId("").setOffset(offset).build();
LocalLogService service = new LocalLogService();
assertThat(service.read(null, request)).isNotNull();
}
use of com.google.apphosting.api.logservice.LogServicePb.LogReadRequest in project appengine-java-standard by GoogleCloudPlatform.
the class LogServiceImplTest method testFutureStorageError.
@Test
public void testFutureStorageError() throws Exception {
LogReadRequest request = createLogReadRequest(null, null, null, null);
ApiProxy.ApiConfig apiConfig = new ApiProxy.ApiConfig();
Future<byte[]> futureMock = immediateFailedFuture(new ApiProxy.ApplicationException(LogServiceError.ErrorCode.STORAGE_ERROR.getNumber(), "Test error detail"));
when(delegate.makeAsyncCall(same(ApiProxy.getCurrentEnvironment()), eq(LogServiceImpl.PACKAGE), eq(LogServiceImpl.READ_RPC_NAME), eq(request.toByteArray()), isA(apiConfig.getClass()))).thenReturn(futureMock);
LogServiceException e = assertThrows(LogServiceException.class, () -> new LogServiceImpl().fetch(LogQuery.Builder.withDefaults()));
assertThat(e).hasMessageThat().isEqualTo("Test error detail");
}
use of com.google.apphosting.api.logservice.LogServicePb.LogReadRequest in project appengine-java-standard by GoogleCloudPlatform.
the class LogServiceImplTest method testGetLogsForLast24Hours.
@Test
public void testGetLogsForLast24Hours() throws Exception {
List<RequestLog> expectedData = getTestData(LogService.DEFAULT_ITEMS_PER_FETCH);
Long startTime = getTimeForNDaysAgo(1, null);
Long endTime = null;
Integer batchSize = null;
LogReadRequest request = createLogReadRequest(startTime, endTime, batchSize, null);
LogReadResponse response = createLogReadResponse(expectedData);
setupExpectations(request, response);
LogQuery query = LogQuery.Builder.withStartTimeUsec(startTime);
List<RequestLogs> actualData = new ArrayList<>();
for (RequestLogs record : new LogServiceImpl().fetch(query)) {
actualData.add(record);
}
String expectedLogs = getJustCombinedRequestFields(expectedData);
String actualLogs = getJustCombinedFields(actualData);
assertThat(actualLogs).isEqualTo(expectedLogs);
}
use of com.google.apphosting.api.logservice.LogServicePb.LogReadRequest in project appengine-java-standard by GoogleCloudPlatform.
the class LogServiceImplTest method testFutureInvalidRequest.
@Test
public void testFutureInvalidRequest() throws Exception {
LogReadRequest request = createLogReadRequest(null, null, null, null);
ApiProxy.ApiConfig apiConfig = new ApiProxy.ApiConfig();
Future<byte[]> futureMock = immediateFailedFuture(new ApiProxy.ApplicationException(LogServiceError.ErrorCode.INVALID_REQUEST.getNumber(), "Test error detail"));
when(delegate.makeAsyncCall(same(ApiProxy.getCurrentEnvironment()), eq(LogServiceImpl.PACKAGE), eq(LogServiceImpl.READ_RPC_NAME), eq(request.toByteArray()), isA(apiConfig.getClass()))).thenReturn(futureMock);
InvalidRequestException e = assertThrows(InvalidRequestException.class, () -> new LogServiceImpl().fetch(LogQuery.Builder.withDefaults()));
assertThat(e).hasMessageThat().isEqualTo("Test error detail");
}
use of com.google.apphosting.api.logservice.LogServicePb.LogReadRequest in project appengine-java-standard by GoogleCloudPlatform.
the class LogServiceImplTest method testFutureUnrecognizedError.
@Test
public void testFutureUnrecognizedError() throws Exception {
LogReadRequest request = createLogReadRequest(null, null, null, null);
ApiProxy.ApiConfig apiConfig = new ApiProxy.ApiConfig();
Future<byte[]> futureMock = immediateFailedFuture(new ApiProxy.ApplicationException(LogServiceError.ErrorCode.STORAGE_ERROR.getNumber(), "Test error detail"));
when(delegate.makeAsyncCall(same(ApiProxy.getCurrentEnvironment()), eq(LogServiceImpl.PACKAGE), eq(LogServiceImpl.READ_RPC_NAME), eq(request.toByteArray()), isA(apiConfig.getClass()))).thenReturn(futureMock);
LogServiceException e = assertThrows(LogServiceException.class, () -> new LogServiceImpl().fetch(LogQuery.Builder.withDefaults()));
assertThat(e).hasMessageThat().isEqualTo("Test error detail");
}
Aggregations