@Test public void testStorageProcess() { loggerObject.insertLog("GET", "/restconf/path1", "10.0.0.1", "body1"); loggerObject.insertLog("POST", "/restconf/path2", "10.0.0.2", "body2"); runnableCaptor.getValue().run(); ArgumentCaptor<InsertTSDRLogRecordInput> argumentCaptor = ArgumentCaptor.forClass(InsertTSDRLogRecordInput.class); verify(tsdrCollectorSpiService).insertTSDRLogRecord(argumentCaptor.capture()); List<TSDRLogRecord> logRecords = argumentCaptor.getValue().getTSDRLogRecord(); assertEquals("/restconf/path1", logRecords.get(0).getNodeID()); assertEquals("METHOD=GET,REMOTE_ADDRESS=10.0.0.1,BODY=body1", logRecords.get(0).getRecordFullText()); assertEquals(0, (long)logRecords.get(0).getIndex()); assertEquals("/restconf/path2", logRecords.get(1).getNodeID()); assertEquals("METHOD=POST,REMOTE_ADDRESS=10.0.0.2,BODY=body2", logRecords.get(1).getRecordFullText()); assertEquals(1, (long)logRecords.get(1).getIndex()); assertEquals(2, logRecords.size()); Mockito.reset(tsdrCollectorSpiService); when(tsdrCollectorSpiService.insertTSDRLogRecord(any())) .thenReturn(RpcResultBuilder.success(new InsertTSDRLogRecordOutputBuilder().build()).buildFuture()); when(tsdrCollectorSpiService.insertTSDRMetricRecord(any())) .thenReturn(RpcResultBuilder.success(new InsertTSDRMetricRecordOutputBuilder().build()).buildFuture()); loggerObject.insertLog("PUT", "/restconf/path3", "10.0.0.3", "body3"); runnableCaptor.getValue().run(); verify(tsdrCollectorSpiService).insertTSDRLogRecord(argumentCaptor.capture()); logRecords = argumentCaptor.getValue().getTSDRLogRecord(); assertEquals("/restconf/path3", logRecords.get(0).getNodeID()); assertEquals("METHOD=PUT,REMOTE_ADDRESS=10.0.0.3,BODY=body3", logRecords.get(0).getRecordFullText()); assertEquals(0, (long)logRecords.get(0).getIndex()); assertEquals(1, logRecords.size()); Mockito.reset(tsdrCollectorSpiService); runnableCaptor.getValue().run(); verify(tsdrCollectorSpiService, Mockito.never()).insertTSDRLogRecord(Mockito.any()); }
public void insertLog(String method, String pathInfo, String remoteAddress, String body) { super.insertLog(pathInfo, System.currentTimeMillis(), "METHOD=" + method + ",REMOTE_ADDRESS=" + remoteAddress + ",BODY=" + body, DataCategory.RESTCONF); }
TSDRRestconfCollectorLogger extends BatchingLogCollector { public void insertLog(String method, String pathInfo, String remoteAddress, String body) { super.insertLog(pathInfo, System.currentTimeMillis(), "METHOD=" + method + ",REMOTE_ADDRESS=" + remoteAddress + ",BODY=" + body, DataCategory.RESTCONF); } }
TSDRRestconfCollectorLogger extends BatchingLogCollector { public void insertLog(String method, String pathInfo, String remoteAddress, String body) { super.insertLog(pathInfo, System.currentTimeMillis(), "METHOD=" + method + ",REMOTE_ADDRESS=" + remoteAddress + ",BODY=" + body, DataCategory.RESTCONF); } @Inject  TSDRRestconfCollectorLogger(TsdrCollectorSpiService tsdrCollectorSpiService,
                                       SchedulerService schedulerService); }
TSDRRestconfCollectorLogger extends BatchingLogCollector { public void insertLog(String method, String pathInfo, String remoteAddress, String body) { super.insertLog(pathInfo, System.currentTimeMillis(), "METHOD=" + method + ",REMOTE_ADDRESS=" + remoteAddress + ",BODY=" + body, DataCategory.RESTCONF); } @Inject  TSDRRestconfCollectorLogger(TsdrCollectorSpiService tsdrCollectorSpiService,
                                       SchedulerService schedulerService); void insertLog(String method, String pathInfo, String remoteAddress, String body); }
TSDRRestconfCollectorLogger extends BatchingLogCollector { public void insertLog(String method, String pathInfo, String remoteAddress, String body) { super.insertLog(pathInfo, System.currentTimeMillis(), "METHOD=" + method + ",REMOTE_ADDRESS=" + remoteAddress + ",BODY=" + body, DataCategory.RESTCONF); } @Inject  TSDRRestconfCollectorLogger(TsdrCollectorSpiService tsdrCollectorSpiService,
                                       SchedulerService schedulerService); void insertLog(String method, String pathInfo, String remoteAddress, String body);  }