Skip to content

Commit

Permalink
fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianHoesel committed Feb 10, 2020
1 parent b96f5b4 commit 3491bcf
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 17 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
### Changed
- ...

## [1.0.2] - 2020-02-10
- die Verkehrsstaerke hat jetzt ein Attribut "dimension" mit dem ersichtlich wird, ob es sich um "Fz/h" oder "Fz/Intervall" handelt. Bei fehlerhaften Daten, wird das Attribut "dimension" leer gelassen.

## [1.0.0] - 2019-01-31
### Added
- ...
- ...
2 changes: 2 additions & 0 deletions de.bitctrl.dav.rest.api/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="build/generated">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#%RAML 1.0
title: BitCtrl CMS JSON API
version: v1
version: v2
protocols: [ HTTPS ]
baseUri: https://bitctrl.de/dav/api/{version}
mediaType: application/json
Expand Down
5 changes: 4 additions & 1 deletion de.bitctrl.dav.rest.api/src/main/resources/types.raml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ types:
datenStatus: string
zeitstempel: datetime
Verkehrsstaerke:
description: Anzahl der Fahrzeuge pro Intervall
description: Anzahl der Fahrzeuge pro Intervall.
type: object
additionalProperties: false
properties:
wert: integer
guete: number
dimension:
type: string
description: Die Dimension für die Verkehrsstärke. Normalersweise "Fz/h" oder "Fz/Intervall". Bei ungültigen Daten "".
Geschwindigkeit:
description: Geschwindigkeit (von Fahrzeugen) in km/h.
type: object
Expand Down
2 changes: 2 additions & 0 deletions de.bitctrl.dav.rest.client/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
Expand All @@ -22,6 +23,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import de.bitctrl.dav.rest.api.model.Verkehrsstaerke;
import de.bitctrl.dav.rest.api.model.VerkehrsstaerkeImpl;
import de.bsvrz.dav.daf.main.Data;
import de.bsvrz.dav.daf.main.Data.NumberValue;
import de.bsvrz.dav.daf.main.ResultData;
import de.bsvrz.dav.daf.main.config.Aspect;

Expand Down Expand Up @@ -88,16 +89,20 @@ static Geschwindigkeit extraktGeschwindigkeit(Data data) {
static Verkehrsstaerke extraktVerkehrsStaerke(Data data) {
final Verkehrsstaerke qKfz = new VerkehrsstaerkeImpl();
if (data.getUnscaledValue("Wert").isState()) {
qKfz.setWert(data.getUnscaledValue("Wert").intValue());
NumberValue unscaledValue = data.getUnscaledValue("Wert");
qKfz.setWert(unscaledValue.intValue());
qKfz.setDimension("");
} else {
qKfz.setWert(data.getScaledValue("Wert").intValue());
NumberValue scaledValue = data.getScaledValue("Wert");
qKfz.setWert(scaledValue.intValue());
qKfz.setDimension(scaledValue.getSuffixText());
}
if (data.getItem("Güte").getUnscaledValue("Index").isState()) {
qKfz.setGuete(data.getItem("Güte").getUnscaledValue("Index").doubleValue());
} else {
qKfz.setGuete(data.getItem("Güte").getScaledValue("Index").doubleValue());
}

return qKfz;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,23 @@ public static void tearDownAfterClass() throws Exception {
dataModel.close();
}

@Parameters(name = "{index}: anzahl->{0}, geschwindigkeit->{1}, guete->{2}, datum->{3}, belegung->{4}")
@Parameters(name = "{index}: anzahl->{0}, geschwindigkeit->{1}, guete->{2}, datum->{3}, belegung->{4}, atg->{5}, asp->{6}")
public static Collection<Object[]> data() {

return Arrays.asList(new Object[][] {
// anahl Fz, geschwindigkeit, güte, datum, belegung
{ -3, -3, 0.2d, LocalDateTime.of(2019, 1, 1, 0, 0), 0 },
{ -2, -2, 0.999d, LocalDateTime.of(2019, 12, 31, 23, 59), 1 },
{ -2, -2, 0.0, LocalDateTime.of(2019, 3, 31, 2, 0), 99 },
{ -1, -1, 1d, LocalDateTime.of(2019, 2, 28, 12, 0), 100 },
{ 0, 0, 0.5d, LocalDateTime.of(2019, 9, 27, 12, 0), 1 },
{ 100, 254, 0.5d, LocalDateTime.of(2019, 3, 14, 12, 0), 55 }
{ -3, -3, 0.2d, LocalDateTime.of(2019, 1, 1, 0, 0), 0,"atg.verkehrsDatenKurzZeitFs","asp.externeErfassung","" },
{ 3, 3, 0.9d, LocalDateTime.of(2019, 1, 1, 0, 0), 1,"atg.verkehrsDatenKurzZeitFs","asp.externeErfassung","Fz/h" },
{ -2, -2, 0.999d, LocalDateTime.of(2019, 12, 31, 23, 59), 1 ,"atg.verkehrsDatenKurzZeitFs","asp.analyse",""},
{ 2, 2, 0.999d, LocalDateTime.of(2019, 12, 31, 23, 59), 1 ,"atg.verkehrsDatenKurzZeitFs","asp.analyse","Fz/h"},
{ -2, -2, 0.0, LocalDateTime.of(2019, 3, 31, 2, 0), 99 ,"atg.verkehrsDatenKurzZeitFs","asp.agregation1Minute",""},
{ 2, 2, 0.0, LocalDateTime.of(2019, 3, 31, 2, 0), 99 ,"atg.verkehrsDatenKurzZeitFs","asp.agregation1Minute","Fz/h"},
{ -1, -1, 1d, LocalDateTime.of(2019, 2, 28, 12, 0), 100 ,"atg.verkehrsDatenKurzZeitFs","asp.agregation5Minuten",""},
{ 1, 1, 1d, LocalDateTime.of(2019, 2, 28, 12, 0), 100 ,"atg.verkehrsDatenKurzZeitFs","asp.agregation5Minuten","Fz/h"},
{ 0, 0, 0.5d, LocalDateTime.of(2019, 9, 27, 12, 0), 1 ,"atg.verkehrsDatenKurzZeitFs","asp.analyse","Fz/h"},
{ 100, 254, 0.5d, LocalDateTime.of(2019, 3, 14, 12, 0), 55,"atg.verkehrsDatenKurzZeitFs","asp.analyse","Fz/h" },
{ 30, 111, 1d, LocalDateTime.of(2020, 2, 10, 12, 0), 12,"atg.verkehrsDatenKurzZeitIntervall","asp.externeErfassung","Fz/Intervall" },
{ 45, 22, 0.1d, LocalDateTime.of(2020,1, 10, 12, 0), 33,"atg.verkehrsDatenKurzZeitIntervall","asp.messWertErsetzung","Fz/Intervall" }

});

Expand All @@ -98,12 +104,21 @@ public static Collection<Object[]> data() {

@Parameter(4)
public int belegung;

@Parameter(5)
public String atgPid;

@Parameter(6)
public String aspPid;

@Parameter(7)
public String dimension;

@Test
public void test() {
final SystemObject fs = dataModel.getObject("test.fs1");
final AttributeGroup atg = dataModel.getAttributeGroup("atg.verkehrsDatenKurzZeitFs");
final Aspect asp = dataModel.getAspect("asp.externeErfassung");
final AttributeGroup atg = dataModel.getAttributeGroup(atgPid);
final Aspect asp = dataModel.getAspect(aspPid);

final Data data = AttributeBaseValueDataFactory.createAdapter(atg, AttributeHelper.getAttributesValues(atg));
data.getItem("qKfz").getUnscaledValue("Wert").set(anzahl);
Expand All @@ -122,13 +137,17 @@ public void test() {

final ResultData rd = new ResultData(fs, new DataDescription(atg, asp),
time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), data);



final VerkehrsDatenKurzZeitFSConverter converter = new VerkehrsDatenKurzZeitFSConverter();
final VerkehrsdatenKurzzeit result = converter.dav2Json(rd).iterator().next();

Assert.assertEquals(anzahl, result.getQKfz().getWert());
Assert.assertEquals(dimension, result.getQKfz().getDimension());
Assert.assertEquals(anzahl, result.getQLkw().getWert());
Assert.assertEquals(dimension, result.getQLkw().getDimension());
Assert.assertEquals(anzahl, result.getQPkw().getWert());
Assert.assertEquals(dimension, result.getQPkw().getDimension());
Assert.assertEquals(geschwindigkeit, result.getVKfz().getWert());
Assert.assertEquals(geschwindigkeit, result.getVLkw().getWert());
Assert.assertEquals(geschwindigkeit, result.getVPkw().getWert());
Expand Down
2 changes: 2 additions & 0 deletions de.bitctrl.dav.rest.server/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
Expand All @@ -22,6 +23,7 @@
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
Expand Down
1 change: 0 additions & 1 deletion de.bitctrl.dav.rest.server/src/test/java/RestTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand Down

0 comments on commit 3491bcf

Please sign in to comment.