@Test public void testInsertTSDRLogRecord() throws InterruptedException, ExecutionException, TimeoutException { doReturn(RpcResultBuilder.success(new StoreTSDRLogRecordOutputBuilder().build()).buildFuture()) .when(logDataService).storeTSDRLogRecord(any()); TSDRLogRecord inputLogRecord = createTSDRLogRecord("Hello World"); final ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> resultFuture = impl.insertTSDRLogRecord( new InsertTSDRLogRecordInputBuilder().setCollectorCodeName("Test") .setTSDRLogRecord(Collections.singletonList(inputLogRecord)).build()); assertTrue(resultFuture.get(5, TimeUnit.SECONDS).isSuccessful()); ArgumentCaptor<StoreTSDRLogRecordInput> storeLogInputCaptor = ArgumentCaptor.forClass(StoreTSDRLogRecordInput.class); verify(logDataService).storeTSDRLogRecord(storeLogInputCaptor.capture()); StoreTSDRLogRecordInput storeLogInput = storeLogInputCaptor.getValue(); assertEquals(1, storeLogInput.getTSDRLogRecord().size()); org.opendaylight.yang.gen.v1.opendaylight.tsdr.log.data.rev160325.storetsdrlogrecord.input.TSDRLogRecord storeLogRecord = storeLogInput.getTSDRLogRecord().iterator().next(); assertEquals(inputLogRecord.getNodeID(), storeLogRecord.getNodeID()); assertEquals(inputLogRecord.getRecordAttributes(), storeLogRecord.getRecordAttributes()); assertEquals(inputLogRecord.getRecordFullText(), storeLogRecord.getRecordFullText()); assertEquals(inputLogRecord.getRecordKeys(), storeLogRecord.getRecordKeys()); assertEquals(inputLogRecord.getTimeStamp(), storeLogRecord.getTimeStamp()); assertEquals(inputLogRecord.getTSDRDataCategory(), storeLogRecord.getTSDRDataCategory()); }
@Override public ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input) { List<TSDRLogRecord> records = input.getTSDRLogRecord().stream().map(inputRec -> new TSDRLogRecordBuilder().setNodeID(inputRec.getNodeID()) .setRecordAttributes(inputRec.getRecordAttributes()) .setRecordFullText(inputRec.getRecordFullText()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setIndex(inputRec.getIndex()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRLogRecordInput tsdrServiceInput = new StoreTSDRLogRecordInputBuilder().setTSDRLogRecord(records).build(); return Futures.transform(logDataService.storeTSDRLogRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRLogRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRLogRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input) { List<TSDRLogRecord> records = input.getTSDRLogRecord().stream().map(inputRec -> new TSDRLogRecordBuilder().setNodeID(inputRec.getNodeID()) .setRecordAttributes(inputRec.getRecordAttributes()) .setRecordFullText(inputRec.getRecordFullText()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setIndex(inputRec.getIndex()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRLogRecordInput tsdrServiceInput = new StoreTSDRLogRecordInputBuilder().setTSDRLogRecord(records).build(); return Futures.transform(logDataService.storeTSDRLogRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRLogRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRLogRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input) { List<TSDRLogRecord> records = input.getTSDRLogRecord().stream().map(inputRec -> new TSDRLogRecordBuilder().setNodeID(inputRec.getNodeID()) .setRecordAttributes(inputRec.getRecordAttributes()) .setRecordFullText(inputRec.getRecordFullText()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setIndex(inputRec.getIndex()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRLogRecordInput tsdrServiceInput = new StoreTSDRLogRecordInputBuilder().setTSDRLogRecord(records).build(); return Futures.transform(logDataService.storeTSDRLogRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRLogRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRLogRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } CollectorSPIImpl(TsdrMetricDataService metricService,TsdrLogDataService logService); }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input) { List<TSDRLogRecord> records = input.getTSDRLogRecord().stream().map(inputRec -> new TSDRLogRecordBuilder().setNodeID(inputRec.getNodeID()) .setRecordAttributes(inputRec.getRecordAttributes()) .setRecordFullText(inputRec.getRecordFullText()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setIndex(inputRec.getIndex()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRLogRecordInput tsdrServiceInput = new StoreTSDRLogRecordInputBuilder().setTSDRLogRecord(records).build(); return Futures.transform(logDataService.storeTSDRLogRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRLogRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRLogRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } CollectorSPIImpl(TsdrMetricDataService metricService,TsdrLogDataService logService); @Override ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord(
            InsertTSDRMetricRecordInput input); @Override ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input); }
CollectorSPIImpl implements TsdrCollectorSpiService { @Override public ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input) { List<TSDRLogRecord> records = input.getTSDRLogRecord().stream().map(inputRec -> new TSDRLogRecordBuilder().setNodeID(inputRec.getNodeID()) .setRecordAttributes(inputRec.getRecordAttributes()) .setRecordFullText(inputRec.getRecordFullText()) .setRecordKeys(inputRec.getRecordKeys()) .setTimeStamp(inputRec.getTimeStamp()) .setIndex(inputRec.getIndex()) .setTSDRDataCategory(inputRec.getTSDRDataCategory()).build()).collect(Collectors.toList()); StoreTSDRLogRecordInput tsdrServiceInput = new StoreTSDRLogRecordInputBuilder().setTSDRLogRecord(records).build(); return Futures.transform(logDataService.storeTSDRLogRecord(tsdrServiceInput), result -> { return result.isSuccessful() ? RpcResultBuilder.success(new InsertTSDRLogRecordOutputBuilder().build()) .build() : RpcResultBuilder.<InsertTSDRLogRecordOutput>failed() .withRpcErrors(result.getErrors()).build(); }, MoreExecutors.directExecutor()); } CollectorSPIImpl(TsdrMetricDataService metricService,TsdrLogDataService logService); @Override ListenableFuture<RpcResult<InsertTSDRMetricRecordOutput>> insertTSDRMetricRecord(
            InsertTSDRMetricRecordInput input); @Override ListenableFuture<RpcResult<InsertTSDRLogRecordOutput>> insertTSDRLogRecord(InsertTSDRLogRecordInput input);  }