Postgres version #1
2 changed files with 33 additions and 29 deletions
|
|
@ -28,19 +28,22 @@ public class JsoCallDecoder {
|
|||
List<String> newCalls = Arrays.stream(updates.split("\n"))
|
||||
.filter(line -> line.contains("added"))
|
||||
.filter(line -> !line.contains("Last refreshed"))
|
||||
.map(line -> line.replace("(added ) ", ""))
|
||||
.map(line -> line.replace("(added )", ""))
|
||||
.map(String::trim)
|
||||
.toList();
|
||||
|
||||
List<JsoCall> jsoCalls = new ArrayList<>();
|
||||
for (String call : newCalls) {
|
||||
String trimmedCall = call.trim();
|
||||
JsoCall jsoCall = new JsoCall();
|
||||
jsoCall.setIncidentNumber(trimmedCall.substring(0, 12));
|
||||
jsoCall.setDispatchedTime(parseTimeWithoutYear(trimmedCall.substring(14, 24).trim()));
|
||||
jsoCall.setAddress(trimmedCall.substring(27, 69).trim());
|
||||
jsoCall.setSignal(trimmedCall.substring(69, 77).trim());
|
||||
jsoCall.setCallDescription(trimmedCall.substring(77).trim());
|
||||
if (!jsoCall.getAddress().contains("I95")) {
|
||||
String[] workingString = call.split(" ", 5);
|
||||
workingString[4] = workingString[4].trim();
|
||||
jsoCall.setIncidentNumber(workingString[0]);
|
||||
jsoCall.setDispatchedTime(parseTimeWithoutYear(workingString[2] + " " + workingString[3].trim()));
|
||||
jsoCall.setAddress(workingString[4].substring(0, 42).trim());
|
||||
jsoCall.setSignal(workingString[4].substring(42, 50).trim());
|
||||
jsoCall.setCallDescription(workingString[4].substring(50).trim());
|
||||
if (!jsoCall.getAddress().contains("I95")
|
||||
&& !jsoCall.getAddress().contains("I295") && !jsoCall.getAddress().contains("I10")) {
|
||||
jsoCall.setPoint(geoCodeAddress(jsoCall.getAddress()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
//package com.c4181.model;
|
||||
//
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.nio.file.Files;
|
||||
//import java.nio.file.Paths;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
//
|
||||
//class JsoCallDecoderTest {
|
||||
//
|
||||
// @Test
|
||||
// void testDecode() throws IOException {
|
||||
// String data = Files.readString(Paths.get("src/test/resources/test-payload.txt"));
|
||||
//
|
||||
// List<JsoCall> calls = JsoCallDecoder.decodeJsoCallUpdates(data);
|
||||
// assertEquals(52, calls.size());
|
||||
// }
|
||||
//}
|
||||
package com.c4181.model;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class JsoCallDecoderTest {
|
||||
|
||||
@Test
|
||||
void testDecode() throws IOException {
|
||||
String data = Files.readString(Paths.get("src/test/resources/test-payload.txt"));
|
||||
|
||||
JsoCallDecoder decoder = new JsoCallDecoder();
|
||||
List<JsoCall> calls = decoder.decodeJsoCallUpdates(data);
|
||||
assertEquals(52, calls.size());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue