added failing test case for bug 3347

This commit is contained in:
Axel Uhl committed 2015-11-02 14:51:21 +01:00
1 parent 7760dea4c2
commit 7d3a9d8f9f
2 files changed
+39 -1

No files matched your search

@@ -0,0 +1,37 @@
package com.sap.sailinig.domain.based.impl;
import static org.junit.Assert.assertSame;
import org.junit.Before;
import org.junit.Test;
import com.sap.sailing.domain.base.BoatClass;
import com.sap.sailing.domain.base.SharedDomainFactory;
import com.sap.sailing.domain.base.impl.SharedDomainFactoryImpl;
import com.sap.sailing.domain.common.BoatClassMasterdata;
/**
* Tests creation and caching of boat classes. See also bug 3347
* (http://bugzilla.sapsailing.com/bugzilla/show_bug.cgi?id=3347).
*
* @author Axel Uhl (d043530)
*
*/
public class BoatClassCacheTest {
private SharedDomainFactory sharedDomainFactory;
@Before
public void setUp() {
sharedDomainFactory = new SharedDomainFactoryImpl(/* raceLogResolver */ null);
}
@Test
public void testQueryingBoatClassByAlternativeNameFirstThenCanonicalizedAlternativeName() {
final BoatClassMasterdata laserMasterData = BoatClassMasterdata.LASER_INT;
final String laserAlternativeName = laserMasterData.getAlternativeNames()[0];
final String unifiedAlternativeName = BoatClassMasterdata.unifyBoatClassName(laserAlternativeName);
final BoatClass laserByDisplayName = sharedDomainFactory.getOrCreateBoatClass(laserMasterData.getDisplayName());
final BoatClass laserByUnifiedAlternativeName = sharedDomainFactory.getOrCreateBoatClass(unifiedAlternativeName);
assertSame(laserByDisplayName, laserByUnifiedAlternativeName);
}
}
@@ -111,7 +111,6 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
/**
* Uses a transient competitor store
* @param raceLogResolver TODO
*/
public SharedDomainFactoryImpl(RaceLogResolver raceLogResolver) {
this(new TransientCompetitorStoreImpl(), raceLogResolver);
@@ -128,6 +127,7 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
boatClassCache = new HashMap<String, BoatClass>();
this.competitorStore = competitorStore;
waypointCache = new ConcurrentHashMap<Serializable, WeakWaypointReference>();
// FIXME ass also bug 3347: mapping to lower case should rather work through a common unification / canonicalization of boat class names
mayStartWithNoUpwindLeg = new HashSet<String>(Arrays.asList(new String[] { "extreme40", "ess", "ess40" }));
courseAreaCache = new HashMap<Serializable, CourseArea>();
configurationMatcherCache = new HashMap<Serializable, DeviceConfigurationMatcher>();
@@ -310,6 +310,7 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
@Override
public BoatClass getOrCreateBoatClass(String name) {
// FIXME ass also bug 3347: mapping to lower case should rather work through a common unification / canonicalization of boat class names
return getOrCreateBoatClass(name, name == null || /* typicallyStartsUpwind */!mayStartWithNoUpwindLeg.contains(name.toLowerCase()));
}