fixed test error in deserializing device identifiers by reworking logic of placeholder device id

This commit is contained in:
Fredrik Teschke committed 2014-05-08 18:24:16 +02:00
1 parent 9c3524bddc
commit 329c4556b4
13 files changed
+54 -21

No files matched your search

@@ -138,6 +138,7 @@ import com.sap.sailing.domain.racelog.tracking.DeviceIdentifier;
import com.sap.sailing.domain.racelog.tracking.DeviceMarkMappingEvent;
import com.sap.sailing.domain.racelog.tracking.RegisterCompetitorEvent;
import com.sap.sailing.domain.racelog.tracking.StartTrackingEvent;
import com.sap.sailing.domain.racelog.tracking.impl.PlaceHolderDeviceIdentifierSerializationHandler;
import com.sap.sailing.domain.tracking.TrackedRegattaRegistry;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sailing.domain.tracking.WindTrack;
@@ -1615,8 +1616,14 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
TypeBasedServiceFinder<DeviceIdentifierMongoHandler> deviceIdentifierServiceFinder, DBObject deviceId)
throws TransformationException, NoCorrespondingServiceRegisteredException {
String deviceType = (String) deviceId.get(FieldNames.DEVICE_TYPE.name());
Object deviceTypeId = deviceId.get(FieldNames.DEVICE_TYPE_ID.name());
Object deviceTypeId = deviceId.get(FieldNames.DEVICE_TYPE_SPECIFIC_ID.name());
String stringRepresentation = (String) deviceId.get(FieldNames.DEVICE_STRING_REPRESENTATION.name());
return deviceIdentifierServiceFinder.findService(deviceType).deserialize(deviceTypeId, deviceType, stringRepresentation);
try {
return deviceIdentifierServiceFinder.findService(deviceType).deserialize(deviceTypeId, deviceType, stringRepresentation);
} catch (TransformationException e) {
return new PlaceHolderDeviceIdentifierSerializationHandler().deserialize(
stringRepresentation, deviceType, stringRepresentation);
}
}
}
@@ -92,5 +92,5 @@ public enum FieldNames {
CONFIGURATION_CONFIG_PROCEDURES,
// GPSFixes
DEVICE_TYPE_ID, DEVICE_ID, DEVICE_TYPE, GPSFIX_TYPE, GPSFIX, DEVICE_STRING_REPRESENTATION,
DEVICE_TYPE_SPECIFIC_ID, DEVICE_ID, DEVICE_TYPE, GPSFIX_TYPE, GPSFIX, DEVICE_STRING_REPRESENTATION,
}
@@ -1140,10 +1140,10 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
DeviceIdentifierMongoHandler handler = deviceIdentifierServiceFinder.findService(type);
Pair<String, ? extends Object> pair = handler.serialize(device);
type = pair.getA();
Object deviceTypeId = pair.getB();
Object deviceTypeSpecificId = pair.getB();
return new BasicDBObjectBuilder()
.add(FieldNames.DEVICE_TYPE.name(), type)
.add(FieldNames.DEVICE_TYPE_ID.name(), deviceTypeId)
.add(FieldNames.DEVICE_TYPE_SPECIFIC_ID.name(), deviceTypeSpecificId)
.add(FieldNames.DEVICE_STRING_REPRESENTATION.name(), device.getStringRepresentation()).get();
}