mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 14:27:15 +00:00
fix for nasty bug 3016: use a new DomainFactoryImpl for each test case execution to get a clean, empty CompetitorStore
This commit is contained in:
1 parent
10bb214083
commit
6d2c319b63
2 files changed
+15
-6
No files matched your search
+1
-1
@@ -1259,7 +1259,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
logger.info("Removing persistent competitor info for competitor "+competitor.getName()+" with ID "+competitor.getId());
|
||||
DBCollection collection = database.getCollection(CollectionNames.COMPETITORS.name());
|
||||
DBObject query = (DBObject) JSON.parse(CompetitorJsonSerializer.getCompetitorIdQuery(competitor).toString());
|
||||
collection.remove(query);
|
||||
collection.remove(query, WriteConcern.SAFE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+14
-5
@@ -8,6 +8,7 @@ import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mongodb.DB;
|
||||
@@ -16,6 +17,7 @@ import com.mongodb.MongoException;
|
||||
import com.mongodb.WriteConcern;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.base.impl.DomainFactoryImpl;
|
||||
import com.sap.sailing.domain.base.impl.DynamicCompetitor;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
@@ -25,11 +27,18 @@ import com.sap.sailing.domain.test.AbstractLeaderboardTest;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
public class StoreCompetitorTest extends AbstractMongoDBTest {
|
||||
|
||||
private DomainFactory domainFactory;
|
||||
|
||||
public StoreCompetitorTest() throws UnknownHostException, MongoException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// clear the domainFactory competitor store for a clean start:
|
||||
domainFactory = new DomainFactoryImpl();
|
||||
}
|
||||
|
||||
private void dropCompetitorCollection() {
|
||||
DB db = getMongoService().getDB();
|
||||
DBCollection competitorCollection = db.getCollection(CollectionNames.COMPETITORS.name());
|
||||
@@ -45,7 +54,7 @@ public class StoreCompetitorTest extends AbstractMongoDBTest {
|
||||
String competitorName2 = "Hasso Plattner";
|
||||
|
||||
MongoObjectFactory mongoObjectFactory = PersistenceFactory.INSTANCE.getMongoObjectFactory(getMongoService());
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), DomainFactory.INSTANCE);
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), domainFactory);
|
||||
dropCompetitorCollection();
|
||||
|
||||
DynamicCompetitor c = AbstractLeaderboardTest.createCompetitor(competitorName1);
|
||||
@@ -72,7 +81,7 @@ public class StoreCompetitorTest extends AbstractMongoDBTest {
|
||||
@Test
|
||||
public void testStoreAndUpdateCompetitorWithUUIDAsId() {
|
||||
MongoObjectFactory mongoObjectFactory = PersistenceFactory.INSTANCE.getMongoObjectFactory(getMongoService());
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), DomainFactory.INSTANCE);
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), domainFactory);
|
||||
dropCompetitorCollection();
|
||||
|
||||
DynamicCompetitor c = AbstractLeaderboardTest.createCompetitor("Hasso", UUID.randomUUID());
|
||||
@@ -86,7 +95,7 @@ public class StoreCompetitorTest extends AbstractMongoDBTest {
|
||||
@Test
|
||||
public void testStoreAndRemoveCompetitor() {
|
||||
MongoObjectFactory mongoObjectFactory = PersistenceFactory.INSTANCE.getMongoObjectFactory(getMongoService());
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), DomainFactory.INSTANCE);
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), domainFactory);
|
||||
dropCompetitorCollection();
|
||||
|
||||
DynamicCompetitor c = AbstractLeaderboardTest.createCompetitor("Hasso");
|
||||
@@ -100,7 +109,7 @@ public class StoreCompetitorTest extends AbstractMongoDBTest {
|
||||
@Test
|
||||
public void testStoreAndRemoveCompetitorWithUUIDAsId() {
|
||||
MongoObjectFactory mongoObjectFactory = PersistenceFactory.INSTANCE.getMongoObjectFactory(getMongoService());
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), DomainFactory.INSTANCE);
|
||||
DomainObjectFactory domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(), domainFactory);
|
||||
dropCompetitorCollection();
|
||||
|
||||
DynamicCompetitor c = AbstractLeaderboardTest.createCompetitor("Hasso", UUID.randomUUID());
|
||||
|
||||
Reference in new issue
Block a user