// Path: metrics-influxdb/src/main/java/com/izettle/metrics/influxdb/data/InfluxDbPoint.java
// public class InfluxDbPoint {
//     private String measurement;
//     private Map<String, String> tags = Collections.emptyMap();
//     private Long time;
//     private Map<String, Object> fields = Collections.emptyMap();
// 
//     public InfluxDbPoint(
//         final String measurement,
//         final Long time,
//         final Map<String, Object> fields) {
//         this.measurement = measurement;
//         this.time = time;
//         if (fields != null) {
//             this.fields = Collections.unmodifiableMap(fields);
//         }
// 
//     }
// 
//     public InfluxDbPoint(
//         String measurement,
//         Map<String, String> tags,
//         Long time,
//         Map<String, Object> fields) {
//         this.measurement = measurement;
//         if (tags != null) {
//             this.tags = Collections.unmodifiableMap(tags);
//         }
//         this.time = time;
//         if (fields != null) {
//             this.fields = Collections.unmodifiableMap(fields);
//         }
//     }
// 
//     public String getMeasurement() {
//         return measurement;
//     }
// 
//     public void setMeasurement(String measurement) {
//         this.measurement = measurement;
//     }
// 
//     public Map<String, String> getTags() {
//         return tags;
//     }
// 
//     public void setTags(Map<String, String> tags) {
//         if (tags != null) {
//             this.tags = Collections.unmodifiableMap(tags);
//         }
//     }
// 
//     public Long getTime() {
//         return time;
//     }
// 
//     public void setTime(Long time) {
//         this.time = time;
//     }
// 
//     public Map<String, Object> getFields() {
//         return fields;
//     }
// 
//     public void setFields(Map<String, Object> fields) {
//         if (fields != null) {
//             this.fields = Collections.unmodifiableMap(fields);
//         }
//     }
// }
// 
// Path: metrics-influxdb/src/main/java/com/izettle/metrics/influxdb/data/InfluxDbWriteObject.java
// public class InfluxDbWriteObject {
// 
//     private String database;
// 
//     private TimeUnit precision;
// 
//     private Set<InfluxDbPoint> points;
// 
//     private Map<String, String> tags = Collections.emptyMap();
// 
//     public InfluxDbWriteObject(final String database, final TimeUnit precision) {
//         this.points = new HashSet<InfluxDbPoint>();
//         this.database = database;
//         this.precision = precision;
//     }
// 
//     public String getDatabase() {
//         return database;
//     }
// 
//     public void setDatabase(String database) {
//         this.database = database;
//     }
// 
//     public TimeUnit getPrecision() {
//         return precision;
//     }
// 
//     public void setPrecision(TimeUnit precision) {
//         this.precision = precision;
//     }
// 
//     public Set<InfluxDbPoint> getPoints() {
//         return points;
//     }
// 
//     public void setPoints(Set<InfluxDbPoint> points) {
//         this.points = points;
//     }
// 
//     public Map<String, String> getTags() {
//         return tags;
//     }
// 
//     public void setTags(Map<String, String> tags) {
//         this.tags = Collections.unmodifiableMap(tags);
//     }
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.izettle.metrics.influxdb.data.InfluxDbPoint;
import com.izettle.metrics.influxdb.data.InfluxDbWriteObject;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
        Map<String, Object> fields2 = new HashMap<String, Object>();
        fields2.put("value", "222");
        InfluxDbPoint point1 = new InfluxDbPoint("aa.bb.cc1", tags, 456l, fields1);
        InfluxDbPoint point2 = new InfluxDbPoint("aa.bb.cc2", tags, 456l, fields2);
        Set<InfluxDbPoint> set = new HashSet<InfluxDbPoint>();
        set.add(point1);
        set.add(point2);
        InfluxDbWriteObject influxDbWriteObject = mock(InfluxDbWriteObject.class);
        when(influxDbWriteObject.getPoints()).thenReturn(set);
        when(influxDbWriteObject.getPrecision()).thenReturn(TimeUnit.MICROSECONDS);
        InfluxDbWriteObjectSerializer influxDbWriteObjectSerializer = new InfluxDbWriteObjectSerializer("");
        String lineString = influxDbWriteObjectSerializer.getGroupedLineProtocolString(influxDbWriteObject, "xxx");
        assertThat(lineString).isEqualTo("xxx,tag1Key=tag1Value bb.cc2=\"222\",bb.cc1=\"111\" 456000\n");
    }

    @Test
    public void undottedMeasurementShouldFallback() {
        Map<String, String> tags = new HashMap<String, String>();
        tags.put("tag1Key", "tag1Value");
        Map<String, Object> fields = new HashMap<String, Object>();
        fields.put("field1Key", "field1Value");
        InfluxDbPoint point1 = new InfluxDbPoint("aaa", tags, 456l, fields);
        Set<InfluxDbPoint> set = new HashSet<InfluxDbPoint>();
        set.add(point1);
        InfluxDbWriteObject influxDbWriteObject = mock(InfluxDbWriteObject.class);
        when(influxDbWriteObject.getPoints()).thenReturn(set);
        when(influxDbWriteObject.getPrecision()).thenReturn(TimeUnit.MICROSECONDS);
        InfluxDbWriteObjectSerializer influxDbWriteObjectSerializer = new InfluxDbWriteObjectSerializer("");
        String lineString = influxDbWriteObjectSerializer.getGroupedLineProtocolString(influxDbWriteObject, "xxx");
        assertThat(lineString).isEqualTo(
// Path: metrics-influxdb/src/main/java/com/izettle/metrics/influxdb/data/InfluxDbPoint.java
// public class InfluxDbPoint {
//     private String measurement;
//     private Map<String, String> tags = Collections.emptyMap();
//     private Long time;
//     private Map<String, Object> fields = Collections.emptyMap();
// 
//     public InfluxDbPoint(
//         final String measurement,
//         final Long time,
//         final Map<String, Object> fields) {
//         this.measurement = measurement;
//         this.time = time;
//         if (fields != null) {
//             this.fields = Collections.unmodifiableMap(fields);
//         }
// 
//     }
// 
//     public InfluxDbPoint(
//         String measurement,
//         Map<String, String> tags,
//         Long time,
//         Map<String, Object> fields) {
//         this.measurement = measurement;
//         if (tags != null) {
//             this.tags = Collections.unmodifiableMap(tags);
//         }
//         this.time = time;
//         if (fields != null) {
//             this.fields = Collections.unmodifiableMap(fields);
//         }
//     }
// 
//     public String getMeasurement() {
//         return measurement;
//     }
// 
//     public void setMeasurement(String measurement) {
//         this.measurement = measurement;
//     }
// 
//     public Map<String, String> getTags() {
//         return tags;
//     }
// 
//     public void setTags(Map<String, String> tags) {
//         if (tags != null) {
//             this.tags = Collections.unmodifiableMap(tags);
//         }
//     }
// 
//     public Long getTime() {
//         return time;
//     }
// 
//     public void setTime(Long time) {
//         this.time = time;
//     }
// 
//     public Map<String, Object> getFields() {
//         return fields;
//     }
// 
//     public void setFields(Map<String, Object> fields) {
//         if (fields != null) {
//             this.fields = Collections.unmodifiableMap(fields);
//         }
//     }
// }
// 
// Path: metrics-influxdb/src/main/java/com/izettle/metrics/influxdb/data/InfluxDbWriteObject.java
// public class InfluxDbWriteObject {
// 
//     private String database;
// 
//     private TimeUnit precision;
// 
//     private Set<InfluxDbPoint> points;
// 
//     private Map<String, String> tags = Collections.emptyMap();
// 
//     public InfluxDbWriteObject(final String database, final TimeUnit precision) {
//         this.points = new HashSet<InfluxDbPoint>();
//         this.database = database;
//         this.precision = precision;
//     }
// 
//     public String getDatabase() {
//         return database;
//     }
// 
//     public void setDatabase(String database) {
//         this.database = database;
//     }
// 
//     public TimeUnit getPrecision() {
//         return precision;
//     }
// 
//     public void setPrecision(TimeUnit precision) {
//         this.precision = precision;
//     }
// 
//     public Set<InfluxDbPoint> getPoints() {
//         return points;
//     }
// 
//     public void setPoints(Set<InfluxDbPoint> points) {
//         this.points = points;
//     }
// 
//     public Map<String, String> getTags() {
//         return tags;
//     }
// 
//     public void setTags(Map<String, String> tags) {
//         this.tags = Collections.unmodifiableMap(tags);
//     }
// }


// Path: metrics-influxdb/src/test/java/com/izettle/metrics/influxdb/utils/InfluxDbWriteObjectSerializerTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.izettle.metrics.influxdb.data.InfluxDbPoint;
import com.izettle.metrics.influxdb.data.InfluxDbWriteObject;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.Test;

        Map<String, Object> fields2 = new HashMap<String, Object>();
        fields2.put("value", "222");
        InfluxDbPoint point1 = new InfluxDbPoint("aa.bb.cc1", tags, 456l, fields1);
        InfluxDbPoint point2 = new InfluxDbPoint("aa.bb.cc2", tags, 456l, fields2);
        Set<InfluxDbPoint> set = new HashSet<InfluxDbPoint>();
        set.add(point1);
        set.add(point2);
        InfluxDbWriteObject influxDbWriteObject = mock(InfluxDbWriteObject.class);
        when(influxDbWriteObject.getPoints()).thenReturn(set);
        when(influxDbWriteObject.getPrecision()).thenReturn(TimeUnit.MICROSECONDS);
        InfluxDbWriteObjectSerializer influxDbWriteObjectSerializer = new InfluxDbWriteObjectSerializer("");
        String lineString = influxDbWriteObjectSerializer.getGroupedLineProtocolString(influxDbWriteObject, "xxx");
        assertThat(lineString).isEqualTo("xxx,tag1Key=tag1Value bb.cc2=\"222\",bb.cc1=\"111\" 456000\n");
    }

    @Test
    public void undottedMeasurementShouldFallback() {
        Map<String, String> tags = new HashMap<String, String>();
        tags.put("tag1Key", "tag1Value");
        Map<String, Object> fields = new HashMap<String, Object>();
        fields.put("field1Key", "field1Value");
        InfluxDbPoint point1 = new InfluxDbPoint("aaa", tags, 456l, fields);
        Set<InfluxDbPoint> set = new HashSet<InfluxDbPoint>();
        set.add(point1);
        InfluxDbWriteObject influxDbWriteObject = mock(InfluxDbWriteObject.class);
        when(influxDbWriteObject.getPoints()).thenReturn(set);
        when(influxDbWriteObject.getPrecision()).thenReturn(TimeUnit.MICROSECONDS);
        InfluxDbWriteObjectSerializer influxDbWriteObjectSerializer = new InfluxDbWriteObjectSerializer("");
        String lineString = influxDbWriteObjectSerializer.getGroupedLineProtocolString(influxDbWriteObject, "xxx");
        assertThat(lineString).isEqualTo(
                "xxx,tag1Key=tag1Value aaa.field1Key=\"field1Value\" 456000\n");