mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-01-25 23:16:33 -06:00
test fixes for annotation builder
This commit is contained in:
parent
a9fd4556ad
commit
31ebdb0d92
@ -2,7 +2,9 @@ package io.nosqlbench.nb.api.annotations;
|
||||
|
||||
import io.nosqlbench.nb.api.Layer;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class AnnotationBuilder implements BuilderFacets.All {
|
||||
private String session;
|
||||
@ -11,6 +13,7 @@ public class AnnotationBuilder implements BuilderFacets.All {
|
||||
private final LinkedHashMap<String, String> labels = new LinkedHashMap<>();
|
||||
private final LinkedHashMap<String, String> details = new LinkedHashMap<>();
|
||||
private Layer layer;
|
||||
private TimeZone timezone = TimeZone.getTimeZone(ZoneId.of("GMT"));
|
||||
|
||||
@Override
|
||||
public AnnotationBuilder layer(Layer layer) {
|
||||
@ -50,6 +53,7 @@ public class AnnotationBuilder implements BuilderFacets.All {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AnnotationBuilder label(String name, String value) {
|
||||
this.labels.put(name, value);
|
||||
@ -64,7 +68,7 @@ public class AnnotationBuilder implements BuilderFacets.All {
|
||||
|
||||
@Override
|
||||
public Annotation build() {
|
||||
return new MutableAnnotation(session, layer, start, end, labels, details).asReadOnly();
|
||||
return new MutableAnnotation(timezone, session, layer, start, end, labels, details).asReadOnly();
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,10 @@ package io.nosqlbench.nb.api.annotations;
|
||||
|
||||
import io.nosqlbench.nb.api.Layer;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
|
||||
public class MutableAnnotation implements Annotation {
|
||||
|
||||
@ -14,9 +15,16 @@ public class MutableAnnotation implements Annotation {
|
||||
private long end = 0L;
|
||||
private Map<String, String> labels = new LinkedHashMap<>();
|
||||
private Map<String, String> details = new LinkedHashMap<>();
|
||||
private ZoneId zoneid = ZoneId.of("GMT");
|
||||
|
||||
public MutableAnnotation(String session, Layer layer, long start, long end, LinkedHashMap<String, String> labels,
|
||||
LinkedHashMap<String, String> details) {
|
||||
public MutableAnnotation(
|
||||
TimeZone timezone,
|
||||
String session,
|
||||
Layer layer,
|
||||
long start,
|
||||
long end,
|
||||
LinkedHashMap<String, String> labels,
|
||||
LinkedHashMap<String, String> details) {
|
||||
this.session = session;
|
||||
this.layer = layer;
|
||||
this.start = start;
|
||||
@ -85,9 +93,13 @@ public class MutableAnnotation implements Annotation {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("session: ").append(getSession()).append("\n");
|
||||
|
||||
sb.append("[").append(new Date(getStart()));
|
||||
ZonedDateTime startTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStart()), zoneid);
|
||||
ZonedDateTime endTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStart()), zoneid);
|
||||
|
||||
|
||||
sb.append("[").append(startTime);
|
||||
if (getStart() != getEnd()) {
|
||||
sb.append(" - ").append(new Date(getEnd()));
|
||||
sb.append(" - ").append(endTime);
|
||||
}
|
||||
sb.append("]\n");
|
||||
sb.append("details:\n");
|
||||
|
@ -25,7 +25,7 @@ public class AnnotationBuilderTest {
|
||||
|
||||
String represented = an1.toString();
|
||||
assertThat(represented).isEqualTo("session: test-session\n" +
|
||||
"[Sun Sep 13 07:26:40 CDT 2020]\n" +
|
||||
"[2020-09-13T12:26:40Z[GMT]]\n" +
|
||||
"details:\n" +
|
||||
" detailk1: detailv1\n" +
|
||||
" detailk2: \n" +
|
||||
|
Loading…
Reference in New Issue
Block a user