mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 10:09:42 +00:00
moved MetadataUpdaterTest to more appropriate package to comply with OSGi fragment rules
This commit is contained in:
1 parent
2e23cb66a6
commit
720697be47
2 files changed
+27
-4
No files matched your search
+2
-2
@@ -113,7 +113,7 @@ public class MetadataCollection extends MongoFixHandler {
|
||||
return result;
|
||||
}
|
||||
|
||||
long getNumberOfFixes(DeviceIdentifier device) throws TransformationException, NoCorrespondingServiceRegisteredException {
|
||||
protected long getNumberOfFixes(DeviceIdentifier device) throws TransformationException, NoCorrespondingServiceRegisteredException {
|
||||
final Document resultDocument = findMetadataObject(device);
|
||||
final long result;
|
||||
if (resultDocument == null) {
|
||||
@@ -142,7 +142,7 @@ public class MetadataCollection extends MongoFixHandler {
|
||||
return result;
|
||||
}
|
||||
|
||||
synchronized <FixT extends Timed> void enqueueMetadataUpdate(DeviceIdentifier device, final Object dbDeviceId,
|
||||
protected synchronized <FixT extends Timed> void enqueueMetadataUpdate(DeviceIdentifier device, final Object dbDeviceId,
|
||||
final int nrOfTotalFixes, TimeRange fixesTimeRange, FixT latestFix) throws TransformationException {
|
||||
final MetadataUpdater metadataUpdaterForDevice = metadataUpdaters.computeIfAbsent(device, d->new MetadataUpdater(this, device));
|
||||
metadataUpdaterForDevice.enqueueMetadataUpdate(device, dbDeviceId, nrOfTotalFixes, fixesTimeRange, latestFix);
|
||||
|
||||
+25
-2
@@ -1,4 +1,4 @@
|
||||
package com.sap.sailing.domain.persistence.racelog.tracking.impl;
|
||||
package com.sap.sailing.domain.racelogtracking.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.sap.sailing.domain.persistence.PersistenceFactory;
|
||||
import com.sap.sailing.domain.persistence.impl.CollectionNames;
|
||||
import com.sap.sailing.domain.persistence.impl.MongoObjectFactoryImpl;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.FixMongoHandler;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.impl.MetadataCollection;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.MockSmartphoneImeiServiceFinderFactory;
|
||||
import com.sap.sailing.domain.racelogtracking.impl.SmartphoneImeiIdentifierImpl;
|
||||
import com.sap.sailing.shared.persistence.device.DeviceIdentifierMongoHandler;
|
||||
@@ -28,6 +29,7 @@ import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.NoCorrespondingServiceRegisteredException;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.TimeRange;
|
||||
import com.sap.sse.common.Timed;
|
||||
import com.sap.sse.common.TransformationException;
|
||||
import com.sap.sse.common.TypeBasedServiceFinder;
|
||||
import com.sap.sse.common.TypeBasedServiceFinderFactory;
|
||||
@@ -54,6 +56,27 @@ public class MetadataUpdaterTest {
|
||||
db.getCollection(CollectionNames.GPS_FIXES_METADATA.name()).withWriteConcern(WriteConcern.MAJORITY).drop(clientSession);
|
||||
}
|
||||
|
||||
private static class MyMetadataCollection extends MetadataCollection {
|
||||
public MyMetadataCollection(MongoObjectFactoryImpl mongoOF,
|
||||
TypeBasedServiceFinder<FixMongoHandler<?>> fixServiceFinder,
|
||||
TypeBasedServiceFinder<DeviceIdentifierMongoHandler> deviceServiceFinder, ReadConcern readConcern,
|
||||
WriteConcern writeConcern, ClientSession clientSession) {
|
||||
super(mongoOF, fixServiceFinder, deviceServiceFinder, readConcern, writeConcern, clientSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized <FixT extends Timed> void enqueueMetadataUpdate(DeviceIdentifier device, final Object dbDeviceId,
|
||||
final int nrOfTotalFixes, TimeRange fixesTimeRange, FixT latestFix) throws TransformationException {
|
||||
super.enqueueMetadataUpdate(device, dbDeviceId, nrOfTotalFixes, fixesTimeRange, latestFix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNumberOfFixes(DeviceIdentifier device)
|
||||
throws TransformationException, NoCorrespondingServiceRegisteredException {
|
||||
return super.getNumberOfFixes(device);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSynchronization() throws TransformationException, NoCorrespondingServiceRegisteredException, InterruptedException {
|
||||
final MockSmartphoneImeiServiceFinderFactory serviceFinderFactory = new MockSmartphoneImeiServiceFinderFactory();
|
||||
@@ -62,7 +85,7 @@ public class MetadataUpdaterTest {
|
||||
MongoObjectFactoryImpl mongoOF = (MongoObjectFactoryImpl) PersistenceFactory.INSTANCE.getDefaultMongoObjectFactory();
|
||||
TypeBasedServiceFinder<FixMongoHandler<?>> fixServiceFinder = createFixServiceFinder(serviceFinderFactory);
|
||||
TypeBasedServiceFinder<DeviceIdentifierMongoHandler> deviceServiceFinder = serviceFinderFactory.createServiceFinder(DeviceIdentifierMongoHandler.class);
|
||||
MetadataCollection metadataCollection = new MetadataCollection(mongoOF, fixServiceFinder, deviceServiceFinder, ReadConcern.MAJORITY, WriteConcern.MAJORITY, clientSession);
|
||||
MyMetadataCollection metadataCollection = new MyMetadataCollection(mongoOF, fixServiceFinder, deviceServiceFinder, ReadConcern.MAJORITY, WriteConcern.MAJORITY, clientSession);
|
||||
Object dbDeviceId = com.sap.sailing.shared.persistence.impl.MongoObjectFactoryImpl.storeDeviceId(deviceServiceFinder, deviceIdentifier);
|
||||
final GPSFixMoving latestFix1 = new GPSFixMovingImpl(new DegreePosition(1, 2), TimePoint.now(), new KnotSpeedWithBearingImpl(6, new DegreeBearingImpl(123)), new DegreeBearingImpl(123));
|
||||
final TimeRange fixesTimeRange1 = TimeRange.create(latestFix1.getTimePoint(), latestFix1.getTimePoint().plus(Duration.ONE_MILLISECOND));
|
||||
Reference in new issue
Block a user