added test

This commit is contained in:
Sandro La Bruzzo 2022-06-20 14:45:50 +02:00
parent 6af85fc542
commit f413122661
1 changed files with 35 additions and 0 deletions

View File

@ -1,9 +1,17 @@
package eu.dnetlib.dhp.monitor;
import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import eu.dnetlib.dhp.monitor.model.AggregationMetric;
import eu.dnetlib.dhp.monitor.model.MonitorException;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*;
/**
@ -78,4 +86,31 @@ public class AggregationMetricsTest {
}
@Test
public void testConnection () throws Exception {
String token = "jhB7Ixgn5uAUhy2Jgwod3rGscifmc30woUln05v0RgRYOqpGzpPTnTIA8bjwbqTXccSVcEfUwiHl_ESrmqz8Lg==";
String bucket = "Aggregation";
String org = "ISTI CNR";
InfluxDBClient client = InfluxDBClientFactory.create("https://ip-90-147-167-221.ct1.garrservices.it:8086", token.toCharArray());
String fileName = "/Users/sandro/Develop/python/monitor/metrics/part-00000";
//read file into stream, try-with-resources
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
final AtomicInteger count=new AtomicInteger(0);
stream.forEach(s-> count.incrementAndGet());
System.out.println("count = " + count.get());
} catch (IOException e) {
e.printStackTrace();
}
}
}