|
39 | 39 | import com.google.logging.v2.CreateLogMetricRequest; |
40 | 40 | import com.google.logging.v2.CreateSinkRequest; |
41 | 41 | import com.google.logging.v2.DeleteLogMetricRequest; |
| 42 | +import com.google.logging.v2.DeleteLogRequest; |
42 | 43 | import com.google.logging.v2.DeleteSinkRequest; |
43 | 44 | import com.google.logging.v2.GetLogMetricRequest; |
44 | 45 | import com.google.logging.v2.GetSinkRequest; |
@@ -84,6 +85,8 @@ public class LoggingImplTest { |
84 | 85 | com.google.api.MonitoredResourceDescriptor.getDefaultInstance(); |
85 | 86 | private static final MonitoredResourceDescriptor DESCRIPTOR = |
86 | 87 | MonitoredResourceDescriptor.fromPb(DESCRIPTOR_PB); |
| 88 | + private static final String LOG_NAME = "log"; |
| 89 | + private static final String LOG_NAME_PB = "projects/" + PROJECT + "/logs/" + LOG_NAME; |
87 | 90 | private static final Function<SinkInfo, LogSink> SINK_TO_PB_FUNCTION = |
88 | 91 | new Function<SinkInfo, LogSink>() { |
89 | 92 | @Override |
@@ -1080,4 +1083,42 @@ public void testListResourceDescriptorAsyncWithOptions() |
1080 | 1083 | assertArrayEquals(descriptorList.toArray(), |
1081 | 1084 | Iterables.toArray(page.values(), MonitoredResourceDescriptor.class)); |
1082 | 1085 | } |
| 1086 | + |
| 1087 | + @Test |
| 1088 | + public void testDeleteLog() { |
| 1089 | + DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(LOG_NAME_PB).build(); |
| 1090 | + Future<Empty> response = Futures.immediateFuture(Empty.getDefaultInstance()); |
| 1091 | + EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response); |
| 1092 | + EasyMock.replay(rpcFactoryMock, loggingRpcMock); |
| 1093 | + logging = options.service(); |
| 1094 | + assertTrue(logging.deleteLog(LOG_NAME)); |
| 1095 | + } |
| 1096 | + |
| 1097 | + @Test |
| 1098 | + public void testDeleteLog_Null() { |
| 1099 | + DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(LOG_NAME_PB).build(); |
| 1100 | + EasyMock.expect(loggingRpcMock.delete(request)).andReturn(Futures.<Empty>immediateFuture(null)); |
| 1101 | + EasyMock.replay(rpcFactoryMock, loggingRpcMock); |
| 1102 | + logging = options.service(); |
| 1103 | + assertFalse(logging.deleteLog(LOG_NAME)); |
| 1104 | + } |
| 1105 | + |
| 1106 | + @Test |
| 1107 | + public void testDeleteLogAync() throws ExecutionException, InterruptedException { |
| 1108 | + DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(LOG_NAME_PB).build(); |
| 1109 | + Future<Empty> response = Futures.immediateFuture(Empty.getDefaultInstance()); |
| 1110 | + EasyMock.expect(loggingRpcMock.delete(request)).andReturn(response); |
| 1111 | + EasyMock.replay(rpcFactoryMock, loggingRpcMock); |
| 1112 | + logging = options.service(); |
| 1113 | + assertTrue(logging.deleteLogAsync(LOG_NAME).get()); |
| 1114 | + } |
| 1115 | + |
| 1116 | + @Test |
| 1117 | + public void testDeleteLogAsync_Null() throws ExecutionException, InterruptedException { |
| 1118 | + DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(LOG_NAME_PB).build(); |
| 1119 | + EasyMock.expect(loggingRpcMock.delete(request)).andReturn(Futures.<Empty>immediateFuture(null)); |
| 1120 | + EasyMock.replay(rpcFactoryMock, loggingRpcMock); |
| 1121 | + logging = options.service(); |
| 1122 | + assertFalse(logging.deleteLogAsync(LOG_NAME).get()); |
| 1123 | + } |
1083 | 1124 | } |
0 commit comments