mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-08 20:12:23 +00:00
Bug 5085: Several test adjustments required after including all device
mappings in the JSON result structure per mark configuration
This commit is contained in:
1 parent
09d8e3b7ee
commit
2febedd92b
3 files changed
+68
-10
No files matched your search
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.selenium.api.coursetemplate;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.selenium.api.core.JsonWrapper;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class DeviceMapping extends JsonWrapper {
|
||||
public static final String FIELD_DEVICE_TYPE = "trackingDeviceType";
|
||||
public static final String FIELD_TRACKING_DEVICE_HASH = "trackingDeviceHash";
|
||||
public static final String FIELD_MAPPED_FROM = "trackingDeviceMappedFromMillis";
|
||||
public static final String FIELD_MAPPED_TO = "trackingDeviceMappedToMillis";
|
||||
|
||||
public DeviceMapping(JSONObject json) {
|
||||
super(json);
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return get(FIELD_TRACKING_DEVICE_HASH);
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return get(FIELD_DEVICE_TYPE);
|
||||
}
|
||||
|
||||
public TimePoint getMappedFrom() {
|
||||
final Number mappedFromMillis = get(FIELD_MAPPED_FROM);
|
||||
return mappedFromMillis == null ? null : new MillisecondsTimePoint(mappedFromMillis.longValue());
|
||||
}
|
||||
|
||||
public TimePoint getMappedTo() {
|
||||
final Number mappedToMillis = get(FIELD_MAPPED_TO);
|
||||
return mappedToMillis == null ? null : new MillisecondsTimePoint(mappedToMillis.longValue());
|
||||
}
|
||||
}
|
||||
+24
-5
@@ -1,7 +1,13 @@
|
||||
package com.sap.sailing.selenium.api.coursetemplate;
|
||||
|
||||
import java.util.UUID;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
@@ -19,7 +25,7 @@ public class MarkConfiguration extends JsonWrapper {
|
||||
private static final String FIELD_MARK_ID = "markId";
|
||||
private static final String FIELD_POSITIONING = "positioning";
|
||||
private static final String FIELD_STORE_TO_INVENTORY = "storeToInventory";
|
||||
private static final String FIELD_MARK_CONFIGURATION_CURRENT_TRACKING_DEVICE_ID = "currentTrackingDeviceId";
|
||||
public static final String FIELD_MARK_CONFIGURATION_TRACKING_DEVICE_MAPPINGS = "trackingDevices";
|
||||
private static final String FIELD_MARK_CONFIGURATION_LAST_KNOWN_POSITION = "lastKnownPosition";
|
||||
private static final String FIELD_LATITUDE_DEG = "latitude_deg";
|
||||
private static final String FIELD_LONGITUDE_DEG = "longitude_deg";
|
||||
@@ -100,9 +106,22 @@ public class MarkConfiguration extends JsonWrapper {
|
||||
getJson().put(FIELD_POSITIONING, null);
|
||||
}
|
||||
|
||||
public DeviceIdentifier getCurrentTrackingDeviceId() {
|
||||
final JSONObject deviceIdentifierJson = (JSONObject) get(FIELD_MARK_CONFIGURATION_CURRENT_TRACKING_DEVICE_ID);
|
||||
return deviceIdentifierJson == null ? null : new DeviceIdentifier(deviceIdentifierJson);
|
||||
public List<DeviceMapping> getDeviceMappings() {
|
||||
final JSONArray deviceMappings = get(FIELD_MARK_CONFIGURATION_TRACKING_DEVICE_MAPPINGS);
|
||||
final List<DeviceMapping> result;
|
||||
if (deviceMappings == null) {
|
||||
result = Collections.emptyList();
|
||||
} else {
|
||||
result = deviceMappings.stream().map(m -> new DeviceMapping((JSONObject) m)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public DeviceMapping getSingleDeviceMapping() {
|
||||
final List<DeviceMapping> deviceMappings = getDeviceMappings();
|
||||
assertEquals(1, deviceMappings.size());
|
||||
return deviceMappings.get(0);
|
||||
}
|
||||
|
||||
public Position getLastKnownPosition() {
|
||||
|
||||
+8
-5
@@ -8,6 +8,7 @@ import static com.sap.sailing.selenium.api.core.ApiContext.createApiContext;
|
||||
import static com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage.goToPage;
|
||||
import static java.lang.System.currentTimeMillis;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -37,6 +38,7 @@ import com.sap.sailing.selenium.api.coursetemplate.CourseConfiguration;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.CourseConfigurationApi;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.CourseTemplate;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.CourseTemplateApi;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.DeviceMapping;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.MarkAppearance;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.MarkConfiguration;
|
||||
import com.sap.sailing.selenium.api.coursetemplate.MarkProperties;
|
||||
@@ -153,12 +155,13 @@ public class CourseConfigurationTest extends AbstractSeleniumTest {
|
||||
assertEquals("shortName is different for " + msgIdentifier, srcAppearance.getShortName(),
|
||||
trgtAppearance.getShortName());
|
||||
}
|
||||
boolean hasNonPingDeviceIdentifier = trgtMarkConfiguration.getCurrentTrackingDeviceId() != null
|
||||
&& !trgtMarkConfiguration.getCurrentTrackingDeviceId().getType().equals("PING");
|
||||
List<DeviceMapping> trgtDeviceMappings = trgtMarkConfiguration.getDeviceMappings();
|
||||
boolean hasNonPingDeviceIdentifier = !trgtDeviceMappings.isEmpty()
|
||||
&& !trgtDeviceMappings.get(0).getType().equals("PING");
|
||||
if (srcPositioning != null) {
|
||||
if (srcPositioning.getDeviceId() != null) {
|
||||
assertEquals("tracking device was not properly mapped for " + msgIdentifier,
|
||||
srcPositioning.getDeviceId().toString(), trgtMarkConfiguration.getCurrentTrackingDeviceId().getId());
|
||||
"smartphoneUUID", trgtDeviceMappings.get(0).getType());
|
||||
} else if (srcPositioning.getLatitudeDeg() != null && srcPositioning.getLongitudeDeg() != null) {
|
||||
assertEquals("position.lat is different for " + msgIdentifier, srcPositioning.getLatitudeDeg(),
|
||||
trgtMarkConfiguration.getLastKnownPosition().getLatDeg(), 0.0001);
|
||||
@@ -438,7 +441,7 @@ public class CourseConfigurationTest extends AbstractSeleniumTest {
|
||||
logger.info("createdCourse: " + createdCourse.getJson());
|
||||
|
||||
final MarkConfiguration mc1a = createdCourse.getMarkConfigurationByEffectiveName("mc1");
|
||||
assertNull(mc1a.getCurrentTrackingDeviceId());
|
||||
assertTrue(mc1a.getDeviceMappings().isEmpty());
|
||||
assertNull(mc1a.getLastKnownPosition());
|
||||
mc1a.setFixedPosition(updatedLatDeg, updatedLongDeg);
|
||||
|
||||
@@ -481,7 +484,7 @@ public class CourseConfigurationTest extends AbstractSeleniumTest {
|
||||
assertEquals(updatedLongDeg, mc1b.getLastKnownPosition().getLngDeg(), .0);
|
||||
|
||||
final MarkConfiguration mc2b = loadedCourse.getMarkConfigurationByEffectiveName("mc2");
|
||||
assertNotNull(mc2b.getCurrentTrackingDeviceId());
|
||||
assertFalse(mc2b.getDeviceMappings().isEmpty());
|
||||
// no new tracking data from the device, but the way it's currently defined, the last known position will reflect only
|
||||
// a position coming from the device identified above, so we expect to find no last known position here (TODO this seems wrong as a last position *is* known based on the ping)
|
||||
assertNull(mc2b.getLastKnownPosition());
|
||||
|
||||
Reference in new issue
Block a user