failing test for open ended device mapping finder

This commit is contained in:
Axel Uhl
2020-03-30 12:17:45 +02:00
parent eb7f88ad69
commit 13da41a969
5 changed files with 79 additions and 14 deletions
@@ -41,13 +41,10 @@ public class DependentStartTimeFinderTest {
@Before
public void setUp() {
author = new LogEventAuthorImpl("Test", 1);
raceLogA = new RaceLogImpl("raceLogA");
raceLogB = new RaceLogImpl("raceLogB");
raceLogC = new RaceLogImpl("raceLogC");
nowMock = mock(TimePoint.class);
raceLogResolver = new RaceLogResolver() {
@Override
public RaceLog resolve(SimpleRaceLogIdentifier identifier) {
@@ -0,0 +1,69 @@
package com.sap.sailing.domain.regattalog.tracking.analyzing.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogDeviceMarkMappingEventImpl;
import com.sap.sailing.domain.abstractlog.regatta.impl.OpenEndedDeviceMappingFinder;
import com.sap.sailing.domain.base.Mark;
import com.sap.sailing.domain.base.impl.MarkImpl;
import com.sap.sailing.domain.racelogtracking.impl.SmartphoneUUIDIdentifierImpl;
import com.sap.sse.common.Duration;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class OpenEndedDeviceMappingFinderTest extends AbstractRegattaLogTrackingTest {
private OpenEndedDeviceMappingFinder finder;
private Mark mappedToMark;
private UUID deviceUuid;
@Before
public void setUp() {
mappedToMark = new MarkImpl(UUID.randomUUID(), "Random Mark");
deviceUuid = UUID.randomUUID();
finder = new OpenEndedDeviceMappingFinder(log, mappedToMark, deviceUuid.toString());
}
@Test
public void findNoOpenEndedMappingBecauseNoMappingExistsAtAll() {
assertNull(finder.analyze()); // no event in the log, so result is expected to be null
}
@Test
public void findNoOpenEndedMappingBecauseAllMappingsAreClosed() {
final RegattaLogDeviceMarkMappingEventImpl mappingEvent1 = new RegattaLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now(), author, mappedToMark,
new SmartphoneUUIDIdentifierImpl(deviceUuid), MillisecondsTimePoint.now(), MillisecondsTimePoint.now().plus(Duration.ONE_HOUR));
log.add(mappingEvent1);
final RegattaLogDeviceMarkMappingEventImpl mappingEvent2 = new RegattaLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now().plus(Duration.ONE_YEAR), author, mappedToMark,
new SmartphoneUUIDIdentifierImpl(deviceUuid), MillisecondsTimePoint.now(), MillisecondsTimePoint.now().plus(Duration.ONE_YEAR).plus(Duration.ONE_HOUR));
log.add(mappingEvent2);
assertNull(finder.analyze()); // both events are closed; expect result to be null
}
@Test
public void findOpenEndedMappingWhenItsLastOfSeveral() {
final RegattaLogDeviceMarkMappingEventImpl mappingEvent1 = new RegattaLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now(), author, mappedToMark,
new SmartphoneUUIDIdentifierImpl(deviceUuid), MillisecondsTimePoint.now(), MillisecondsTimePoint.now().plus(Duration.ONE_HOUR));
log.add(mappingEvent1);
final RegattaLogDeviceMarkMappingEventImpl mappingEvent2 = new RegattaLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now().plus(Duration.ONE_YEAR), author, mappedToMark,
new SmartphoneUUIDIdentifierImpl(deviceUuid), MillisecondsTimePoint.now(), /* open end */ null);
log.add(mappingEvent2);
assertEquals(mappingEvent2.getId(), finder.analyze());
}
@Test
public void findOpenEndedMappingWhenItsFirstOfSeveral() {
final RegattaLogDeviceMarkMappingEventImpl mappingEvent1 = new RegattaLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now(), author, mappedToMark,
new SmartphoneUUIDIdentifierImpl(deviceUuid), MillisecondsTimePoint.now(), /* open end */ null);
log.add(mappingEvent1);
final RegattaLogDeviceMarkMappingEventImpl mappingEvent2 = new RegattaLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now().plus(Duration.ONE_YEAR), author, mappedToMark,
new SmartphoneUUIDIdentifierImpl(deviceUuid), MillisecondsTimePoint.now(), MillisecondsTimePoint.now().plus(Duration.ONE_YEAR).plus(Duration.ONE_HOUR));
log.add(mappingEvent1);
assertEquals(mappingEvent2.getId(), finder.analyze());
}
}