Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality #41

Merged
merged 20 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ addons:
branches:
- master
- develop
- refactor
script:
- mvn clean
- mvn org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
Expand Down
68 changes: 34 additions & 34 deletions jpo-ode-common/pom.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>jpo-ode-common</artifactId>
<name>jpo-ode-common</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-client-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>jpo-ode-common</artifactId>
<name>jpo-ode-common</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-client-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
</project>
152 changes: 76 additions & 76 deletions jpo-ode-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>jpo-ode-core</artifactId>
<packaging>jar</packaging>
<artifactId>jpo-ode-core</artifactId>
<packaging>jar</packaging>

<name>jpo-ode-core</name>
<description>JPO ODE Core Components</description>
<name>jpo-ode-core</name>
<description>JPO ODE Core Components</description>

<parent>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode-plugins</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>us.dot.its.jpo.ode</groupId>
<artifactId>jpo-ode-plugins</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>0.10.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>0.10.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

import org.junit.Test;

import junit.framework.TestCase;
import us.dot.its.jpo.ode.util.DateTimeUtils;

public class DateTimeUtilsTest extends TestCase {

@Test
public void testIsoDateTime() throws ParseException {
ZonedDateTime expectedDate = ZonedDateTime.now(ZoneOffset.UTC);
String sExpectedDate = DateTimeUtils.isoDateTime(expectedDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;

import org.junit.Test;

import junit.framework.TestCase;
import us.dot.its.jpo.ode.util.GeoUtils;
import us.dot.its.jpo.ode.util.LengthUtils;
Expand All @@ -12,6 +14,7 @@ public class GeoUtilsTest extends TestCase {
public void testNearestPointOnLine() {
}

@Test
public void testPointOffset() {
assertOffset(5.0, 5.0, 10.0, 5.0, 5.0, 8.0); //0 deg
assertOffset(5.0, 5.0, 10.0, 10.0, 2.878, 7.121); //45 deg
Expand All @@ -23,6 +26,7 @@ public void testPointOffset() {
assertOffset(5.0, 5.0, 10.0, 0.0, 7.121, 7.121); //315 deg
}

@Test
public void assertOffset(double ax, double ay, double bx, double by, double ox, double oy) {
Point2D a = new Point2D.Double(ax, ay);
Point2D b = new Point2D.Double(bx, by);
Expand All @@ -37,6 +41,7 @@ public void assertOffset(double ax, double ay, double bx, double by, double ox,
assertEquals((long) (oy * scale), p1y);
}

@Test
public void testDistanceInMapCoordinates() {
double aLat = 43.652969118285434;
double aLng = -85.94707489013672;
Expand Down Expand Up @@ -65,6 +70,7 @@ public void testDistanceInMapCoordinates() {
assertEquals(d1, d3, GeoUtils.ERROR_MARGIN);
}

@Test
public void testDistanceInLatLng() {
double aLat = 43.652969118285434;
double aLng = -85.94707489013672;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.Iterator;
import java.util.Map.Entry;

import org.junit.Test;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -24,30 +26,36 @@ public void testFromToJson() {
// assertEquals(OVDF, JsonUtils.toJson(ovdf));
}

@Test
public void testNewJson() {
String json = JsonUtils.newJson("key1", "value1");
assertEquals("{\"key1\":value1}", json);
}

@Test
public void testNewObjectNode() {
ObjectNode objectNode = JsonUtils.newObjectNode("key1", "value1");
assertEquals("{\"key1\":value1}", objectNode.toString());
}

@Test
public void testAddNode() {
ObjectNode tree = JsonUtils.newObjectNode("key1", "value1");
ObjectNode tree2 = JsonUtils.addNode(tree, "key2", "value2");
assertEquals("{\"key1\":value1,\"key2\":value2}", tree2.toString());
}

@Test
public void testGetJson() {
assertEquals("10817812-036b-4d7b-867b-ae0bc62a2b3e.0", JsonUtils.getJsonNode(OVDF, "serialId").textValue());
}

@Test
public void testNewNode() {
assertEquals("{}", JsonUtils.newNode().toString());
}

@Test
public void testToObjectNode() throws JsonProcessingException, IOException {
ObjectNode ovdf = JsonUtils.toObjectNode(OVDF);
String expectedOvdf = "{\"className\":\"com.bah.ode.model.OdeVehicleDataFlat\",\"serialId\":\"10817812-036b-4d7b-867b-ae0bc62a2b3e.0\",\"receivedAt\":\"2015-07-22T19:21:16.413+0000\",\"groupId\":\"4130008F\",\"accelLong\":0.34,\"accelVert\":0.0,\"accellYaw\":8.42,\"heading\":65.95,\"speed\":8.12,\"sizeLength\":500,\"sizeWidth\":200,\"latitude\":42.3296667,\"longitude\":-83.044539,\"elevation\":156.9,\"tempId\":\"C4290123\",\"year\":2015,\"month\":5,\"day\":13,\"hour\":15,\"minute\":52,\"second\":45.5,\"dateTime\":\"2015-06-13T19:52:45.500+0000\"}";
Expand All @@ -56,13 +64,15 @@ public void testToObjectNode() throws JsonProcessingException, IOException {
assertEquals("{\"className\":\"com.bah.ode.model.OdeVehicleDataFlat\",\"serialId\":\"10817812-036b-4d7b-867b-ae0bc62a2b3e.0\",\"receivedAt\":\"2015-07-22T19:21:16.413+0000\",\"groupId\":\"4130008F\",\"accelLong\":0.34,\"accelVert\":0.0,\"accellYaw\":8.42,\"heading\":65.95,\"speed\":8.12,\"sizeLength\":500,\"sizeWidth\":200,\"latitude\":42.3296667,\"longitude\":-83.044539,\"elevation\":156.9,\"tempId\":\"C4290123\",\"year\":2015,\"month\":5,\"day\":13,\"hour\":15,\"minute\":52,\"second\":45.5,\"dateTime\":\"2015-06-13T19:52:45.500+0000\",\"avgSpeed\":2.22}", ovdf.toString());
}

@Test
public void testPutObject() {
ObjectNode dm = JsonUtils.newNode();
dm.putObject("metadata");
dm.putObject(AppContext.PAYLOAD_STRING).setAll(JsonUtils.newObjectNode("key1", "value1"));
assertEquals("{\"metadata\":{},\"payload\":{\"key1\":value1}}", dm.toString());
}

@Test
public void testJsonNodeToHashMap() {
JsonNode jsonNode = JsonUtils.getJsonNode(ODM, AppContext.PAYLOAD_STRING);
HashMap<String, JsonNode> hashMap = JsonUtils.jsonNodeToHashMap(jsonNode);
Expand Down
Loading