From c21834ca2414ef01cafc8fb42e8fb1614f652bf6 Mon Sep 17 00:00:00 2001 From: Pawel Nowak Date: Sat, 8 Aug 2020 10:19:31 +0200 Subject: [PATCH] delete jongo and com.mongodb.DB support --- README.md | 61 +++++++++---------- pom.xml | 9 +-- .../java/com/github/mongobeej/Mongobee.java | 42 +++---------- .../github/mongobeej/dao/ChangeEntryDao.java | 42 +++++++------ .../github/mongobeej/MongobeeBaseTest.java | 5 ++ .../github/mongobeej/MongobeeProfileTest.java | 3 +- .../com/github/mongobeej/MongobeeTest.java | 32 +++------- .../AnotherMongobeeTestResource.java | 21 ++----- .../test/changelogs/MongobeeTestResource.java | 22 +------ .../mongobeej/utils/ChangeServiceTest.java | 4 +- 10 files changed, 88 insertions(+), 153 deletions(-) diff --git a/README.md b/README.md index 5c0a176..405e965 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ With Maven com.github.cybuch mongobeej - 0.17 + 1.0.0 ``` With Gradle ```groovy -compile 'com.github.cybuch:mongobeej:0.17' +compile 'com.github.cybuch:mongobeej:1.0.0' ``` ### Migrating from Mongobee @@ -38,9 +38,22 @@ In this case the migration process will be executed automatically on startup. ```java @Bean -public Mongobee mongobee(){ +public Mongobee mongobee() { Mongobee runner = new Mongobee("mongodb://YOUR_DB_HOST:27017/DB_NAME"); - runner.setDbName("yourDbName"); // host must be set if not set in URI + runner.setDbName("yourDbName"); // db name must be set if not set in URI + runner.setChangeLogsScanPackage( + "com.example.yourapp.changelogs"); // the package to be scanned for changesets + return runner; +} +``` + +or + +```java +@Bean +public Mongobee mongobee(MongoClient mongoClient) { + Mongobee runner = new MongobeemongoClient); + runner.setDbName("yourDbName"); // db name must be set runner.setChangeLogsScanPackage( "com.example.yourapp.changelogs"); // the package to be scanned for changesets return runner; @@ -53,7 +66,7 @@ Using mongobee without a spring context has similar configuration but you have t ```java Mongobee runner = new Mongobee("mongodb://YOUR_DB_HOST:27017/DB_NAME"); -runner.setDbName("yourDbName"); // host must be set if not set in URI +runner.setDbName("yourDbName"); // db name must be set if not set in URI runner.setChangeLogsScanPackage( "com.example.yourapp.changelogs"); // package to scan for changesets runner.execute(); // ------> starts migration changesets @@ -71,7 +84,7 @@ MongoDB URI format: ``` mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database[.collection]][?options]] ``` -[More about URI](http://mongodb.github.io/mongo-java-driver/3.5/javadoc/) +[More about URI](https://docs.mongodb.com/manual/reference/connection-string/) ### Creating change logs @@ -85,7 +98,7 @@ package com.example.yourapp.changelogs; public class DatabaseChangelog { @ChangeSet(order = "001", id = "someChangeId", author = "testAuthor") - public void importantWorkToDo(DB db){ + public void importantWorkToDo(MongoTemplate mongoTemplate) { // task implementation } } @@ -134,34 +147,16 @@ public void someChange2(MongoDatabase db) { mycollection.insertOne(doc); } -@ChangeSet(order = "003", id = "someChangeWithDb", author = "testAuthor") -public void someChange3(DB db) { - // This is deprecated in mongo-java-driver 3.x, use MongoDatabase instead - // type: com.mongodb.DB : original MongoDB driver v. 2.x, operations allowed by driver are possible - // example: - DBCollection mycollection = db.getCollection("mycollection"); - BasicDBObject doc = new BasicDBObject().append("test", "1"); - mycollection .insert(doc); -} - -@ChangeSet(order = "004", id = "someChangeWithJongo", author = "testAuthor") -public void someChange4(Jongo jongo) { - // type: org.jongo.Jongo : Jongo driver can be used, used for simpler notation - // example: - MongoCollection mycollection = jongo.getCollection("mycollection"); - mycollection.insert("{test : 1}"); -} - -@ChangeSet(order = "005", id = "someChangeWithSpringDataTemplate", author = "testAuthor") -public void someChange5(MongoTemplate mongoTemplate) { +@ChangeSet(order = "003", id = "someChangeWithSpringDataTemplate", author = "testAuthor") +public void someChange3(MongoTemplate mongoTemplate) { // type: org.springframework.data.mongodb.core.MongoTemplate // Spring Data integration allows using MongoTemplate in the ChangeSet // example: mongoTemplate.save(myEntity); } -@ChangeSet(order = "006", id = "someChangeWithSpringDataTemplate", author = "testAuthor") -public void someChange5(MongoTemplate mongoTemplate, Environment environment) { +@ChangeSet(order = "004", id = "someChangeWithSpringDataTemplate", author = "testAuthor") +public void someChange4(MongoTemplate mongoTemplate, Environment environment) { // type: org.springframework.data.mongodb.core.MongoTemplate // type: org.springframework.core.env.Environment // Spring Data integration allows using MongoTemplate and Environment in the ChangeSet @@ -177,7 +172,7 @@ _Example 1_: annotated change set will be invoked for a `dev` profile ```java @Profile("dev") @ChangeSet(author = "testuser", id = "myDevChangest", order = "01") -public void devEnvOnly(DB db){ +public void devEnvOnly(MongoTemplate mongoTemplate) { // ... } ``` @@ -187,7 +182,7 @@ _Example 2_: all change sets in a changelog will be invoked for a `test` profile @Profile("test") public class ChangelogForTestEnv{ @ChangeSet(author = "testuser", id = "myTestChangest", order = "01") - public void testingEnvOnly(DB db){ + public void testingEnvOnly(MongoTemplate mongoTemplate) { // ... } } @@ -226,13 +221,13 @@ You can exclude mongo-java-driver from **mongobeeJ** and use your dependency on org.mongodb mongo-java-driver - 3.0.0 + 3.12.7 com.github.mongobeej mongobeej - 0.17 + 1.0.0 org.mongodb diff --git a/pom.xml b/pom.xml index d1f09cb..516c548 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ com.github.cybuch mongobeej - 0.18-SNAPSHOT + 1.0.0 @@ -54,7 +54,7 @@ org.mongodb mongo-java-driver - 3.9.1 + 3.12.7 org.springframework @@ -71,11 +71,6 @@ reflections 0.9.11 - - org.jongo - jongo - 1.4.0 - org.springframework.data spring-data-mongodb diff --git a/src/main/java/com/github/mongobeej/Mongobee.java b/src/main/java/com/github/mongobeej/Mongobee.java index 3938fc3..5b37178 100644 --- a/src/main/java/com/github/mongobeej/Mongobee.java +++ b/src/main/java/com/github/mongobeej/Mongobee.java @@ -7,10 +7,12 @@ import com.github.mongobeej.exception.MongobeeConnectionException; import com.github.mongobeej.exception.MongobeeException; import com.github.mongobeej.utils.ChangeService; -import com.mongodb.*; +import com.mongodb.MongoClient; +import com.mongodb.MongoClientOptions; +import com.mongodb.MongoClientSettings; +import com.mongodb.MongoClientURI; import com.mongodb.client.MongoClients; import com.mongodb.client.MongoDatabase; -import org.jongo.Jongo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; @@ -41,9 +43,7 @@ public class Mongobee implements InitializingBean { private static final long DEFAULT_CHANGE_LOG_LOCK_WAIT_TIME = 5L; private static final long DEFAULT_CHANGE_LOG_LOCK_POLL_RATE = 10L; private static final boolean DEFAULT_THROW_EXCEPTION_IF_CANNOT_OBTAIN_LOCK = false; - private ChangeEntryDao dao; - private boolean enabled = true; private String changeLogsScanPackage; private MongoClientURI mongoClientURI; @@ -51,9 +51,7 @@ public class Mongobee implements InitializingBean { private com.mongodb.client.MongoClient mongoClient; private String dbName; private Environment springEnvironment; - private MongoTemplate mongoTemplate; - private Jongo jongo; /** @@ -159,7 +157,9 @@ public void execute() throws MongobeeException { validateConfig(); - if (this.legacyMongoClient != null) { + if (mongoClient != null) { + dao.connectMongoDb(mongoClient, dbName); + } else if (this.legacyMongoClient != null) { dao.connectMongoDb(this.legacyMongoClient, dbName); } else { dao.connectMongoDb(this.mongoClientURI, dbName); @@ -188,7 +188,7 @@ private void executeMigration() throws MongobeeConnectionException, MongobeeExce for (Class changelogClass : service.fetchChangeLogs()) { - Object changelogInstance = null; + Object changelogInstance; try { changelogInstance = changelogClass.getConstructor().newInstance(); List changesetMethods = service.fetchChangeSets(changelogInstance.getClass()); @@ -198,11 +198,11 @@ private void executeMigration() throws MongobeeConnectionException, MongobeeExce try { if (dao.isNewChange(changeEntry)) { - executeChangeSetMethod(changesetMethod, changelogInstance, dao.getDb(), dao.getMongoDatabase()); + executeChangeSetMethod(changesetMethod, changelogInstance, dao.getMongoDatabase()); dao.save(changeEntry); logger.info(changeEntry + " applied"); } else if (service.isRunAlwaysChangeSet(changesetMethod)) { - executeChangeSetMethod(changesetMethod, changelogInstance, dao.getDb(), dao.getMongoDatabase()); + executeChangeSetMethod(changesetMethod, changelogInstance, dao.getMongoDatabase()); logger.info(changeEntry + " reapplied"); } else { logger.info(changeEntry + " passed over"); @@ -223,20 +223,9 @@ private void executeMigration() throws MongobeeConnectionException, MongobeeExce private Object executeChangeSetMethod( Method changeSetMethod, Object changeLogInstance, - DB db, MongoDatabase mongoDatabase ) throws IllegalAccessException, InvocationTargetException, MongobeeChangeSetException { if (changeSetMethod.getParameterTypes().length == 1 - && changeSetMethod.getParameterTypes()[0].equals(DB.class)) { - logger.debug("method with DB argument"); - - return changeSetMethod.invoke(changeLogInstance, db); - } else if (changeSetMethod.getParameterTypes().length == 1 - && changeSetMethod.getParameterTypes()[0].equals(Jongo.class)) { - logger.debug("method with Jongo argument"); - - return changeSetMethod.invoke(changeLogInstance, jongo != null ? jongo : new Jongo(db)); - } else if (changeSetMethod.getParameterTypes().length == 1 && changeSetMethod.getParameterTypes()[0].equals(MongoTemplate.class)) { logger.debug("method with MongoTemplate argument"); @@ -455,17 +444,6 @@ public Mongobee setMongoTemplate(MongoTemplate mongoTemplate) { return this; } - /** - * Sets pre-configured {@link MongoTemplate} instance to use by the Mongobee - * - * @param jongo {@link Jongo} instance - * @return Mongobee object for fluent interface - */ - public Mongobee setJongo(Jongo jongo) { - this.jongo = jongo; - return this; - } - /** * Overwrites a default mongobeej changelog collection hardcoded in DEFAULT_CHANGELOG_COLLECTION_NAME. *

diff --git a/src/main/java/com/github/mongobeej/dao/ChangeEntryDao.java b/src/main/java/com/github/mongobeej/dao/ChangeEntryDao.java index 5207fff..fcf5549 100644 --- a/src/main/java/com/github/mongobeej/dao/ChangeEntryDao.java +++ b/src/main/java/com/github/mongobeej/dao/ChangeEntryDao.java @@ -4,9 +4,9 @@ import com.github.mongobeej.exception.MongobeeConfigurationException; import com.github.mongobeej.exception.MongobeeConnectionException; import com.github.mongobeej.exception.MongobeeLockException; -import com.mongodb.DB; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; +import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import org.bson.Document; @@ -21,8 +21,8 @@ public class ChangeEntryDao { private static final Logger logger = LoggerFactory.getLogger("Mongobee dao"); private MongoDatabase mongoDatabase; - private DB db; // only for Jongo driver compatibility - do not use in other contexts - private MongoClient mongoClient; + private com.mongodb.client.MongoClient mongoClient; + private MongoClient legacyMongoClient; private ChangeEntryIndexDao indexDao; private String changelogCollectionName; private boolean waitForLock; @@ -52,24 +52,26 @@ public MongoDatabase getMongoDatabase() { return mongoDatabase; } - /** - * @return com.mongodb.DB - * @deprecated implemented only for Jongo driver compatibility and backward compatibility - do not use in other contexts - */ - public DB getDb() { - return db; + public MongoDatabase connectMongoDb(com.mongodb.client.MongoClient mongoClient, String dbName) throws MongobeeConfigurationException { + if (!hasText(dbName)) { + throw new MongobeeConfigurationException("DB name is not set. Should be defined in MongoDB URI or via setter"); + } else { + this.mongoClient = mongoClient; + mongoDatabase = mongoClient.getDatabase(dbName); + ensureChangeLogCollectionIndex(mongoDatabase.getCollection(changelogCollectionName)); + initializeLock(); + return mongoDatabase; + } } + + @Deprecated public MongoDatabase connectMongoDb(MongoClient mongo, String dbName) throws MongobeeConfigurationException { if (!hasText(dbName)) { throw new MongobeeConfigurationException("DB name is not set. Should be defined in MongoDB URI or via setter"); } else { - - this.mongoClient = mongo; - - db = mongo.getDB(dbName); // for Jongo driver and backward compatibility (constructor has required parameter Jongo(DB) ) + this.legacyMongoClient = mongo; mongoDatabase = mongo.getDatabase(dbName); - ensureChangeLogCollectionIndex(mongoDatabase.getCollection(changelogCollectionName)); initializeLock(); return mongoDatabase; @@ -77,9 +79,8 @@ public MongoDatabase connectMongoDb(MongoClient mongo, String dbName) throws Mon } public MongoDatabase connectMongoDb(MongoClientURI mongoClientURI, String dbName) - throws MongobeeConfigurationException, MongobeeConnectionException { - - final MongoClient mongoClient = new MongoClient(mongoClientURI); + throws MongobeeConfigurationException { + final com.mongodb.client.MongoClient mongoClient = MongoClients.create(mongoClientURI.toString()); final String database = (!hasText(dbName)) ? mongoClientURI.getDatabase() : dbName; return this.connectMongoDb(mongoClient, database); } @@ -166,7 +167,12 @@ private void ensureChangeLogCollectionIndex(MongoCollection collection } public void close() { - this.mongoClient.close(); + if (legacyMongoClient != null) { + legacyMongoClient.close(); + } + if (mongoClient != null) { + mongoClient.close(); + } } private void initializeLock() { diff --git a/src/test/java/com/github/mongobeej/MongobeeBaseTest.java b/src/test/java/com/github/mongobeej/MongobeeBaseTest.java index 6bdcb47..adf01ca 100644 --- a/src/test/java/com/github/mongobeej/MongobeeBaseTest.java +++ b/src/test/java/com/github/mongobeej/MongobeeBaseTest.java @@ -4,6 +4,7 @@ import com.github.mongobeej.dao.ChangeEntryDao; import com.github.mongobeej.dao.ChangeEntryIndexDao; import com.github.mongobeej.utils.MongoEnvironmentCreator; +import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoDatabase; import org.junit.Before; @@ -31,6 +32,10 @@ public void init() throws Exception { mongoDatabase = mongoEnvironment.getMongoDatabase(); when(changeEntryDao.connectMongoDb(any(MongoClientURI.class), anyString())) .thenReturn(mongoDatabase); + when(changeEntryDao.connectMongoDb(any(com.mongodb.client.MongoClient.class), anyString())) + .thenReturn(mongoDatabase); + when(changeEntryDao.connectMongoDb(any(MongoClient.class), anyString())) + .thenReturn(mongoDatabase); when(changeEntryDao.getMongoDatabase()).thenReturn(mongoDatabase); when(changeEntryDao.acquireProcessLock()).thenReturn(true); doCallRealMethod().when(changeEntryDao).save(any(ChangeEntry.class)); diff --git a/src/test/java/com/github/mongobeej/MongobeeProfileTest.java b/src/test/java/com/github/mongobeej/MongobeeProfileTest.java index a0f3887..c3930ed 100644 --- a/src/test/java/com/github/mongobeej/MongobeeProfileTest.java +++ b/src/test/java/com/github/mongobeej/MongobeeProfileTest.java @@ -18,7 +18,7 @@ @RunWith(MockitoJUnitRunner.class) public class MongobeeProfileTest extends MongobeeBaseTest { - private static final int CHANGELOG_COUNT = 13; + private static final int CHANGELOG_COUNT = 10; @Test public void shouldRunDevProfileAndNonAnnotated() throws Exception { @@ -133,6 +133,5 @@ public void shouldRunAllChangeSets() throws Exception { @After public void cleanUp() { mongobee.setMongoTemplate(null); - mongobee.setJongo(null); } } diff --git a/src/test/java/com/github/mongobeej/MongobeeTest.java b/src/test/java/com/github/mongobeej/MongobeeTest.java index 3c08a5c..ca38fe9 100644 --- a/src/test/java/com/github/mongobeej/MongobeeTest.java +++ b/src/test/java/com/github/mongobeej/MongobeeTest.java @@ -7,11 +7,10 @@ import com.github.mongobeej.exception.MongobeeException; import com.github.mongobeej.test.changelogs.MongobeeTestResource; import com.github.mongobeej.utils.MongoEnvironmentCreator.MongoEnvironment; -import com.mongodb.DB; +import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoDatabase; import org.bson.Document; -import org.jongo.Jongo; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -42,8 +41,6 @@ public class MongobeeTest { private ChangeEntryDao changeEntryDao; @Mock private ChangeEntryIndexDao indexDao; - @Mock - private DB db; private MongoDatabase mongoDatabase; @Before @@ -51,9 +48,10 @@ public void init() throws MongobeeException { mongoDatabase = mongoEnvironment.getMongoDatabase(); when(changeEntryDao.connectMongoDb(any(MongoClientURI.class), anyString())) .thenReturn(mongoDatabase); - when(changeEntryDao.getDb()).thenReturn(db); - when(db.getMongo()).thenReturn(mongoEnvironment.getMongoClient()); - when(db.getName()).thenReturn(DB_NAME); + when(changeEntryDao.connectMongoDb(any(com.mongodb.client.MongoClient.class), anyString())) + .thenReturn(mongoDatabase); + when(changeEntryDao.connectMongoDb(any(MongoClient.class), anyString())) + .thenReturn(mongoDatabase); when(changeEntryDao.getMongoDatabase()).thenReturn(mongoDatabase); doCallRealMethod().when(changeEntryDao).save(any(ChangeEntry.class)); doCallRealMethod().when(changeEntryDao).setChangelogCollectionName(anyString()); @@ -83,7 +81,7 @@ public void shouldExecuteAllChangeSets() throws Exception { mongobee.execute(); // then - verify(changeEntryDao, times(13)).save(any(ChangeEntry.class)); // 13 changesets saved to dbchangelog + verify(changeEntryDao, times(10)).save(any(ChangeEntry.class)); // 10 changesets saved to dbchangelog // dbchangelog collection checking long change1 = mongoDatabase.getCollection(CHANGELOG_COLLECTION_NAME) @@ -98,12 +96,9 @@ public void shouldExecuteAllChangeSets() throws Exception { long change4 = mongoDatabase.getCollection(CHANGELOG_COLLECTION_NAME) .count(changeQuery("test4")); assertEquals(1, change4); - long change5 = mongoDatabase.getCollection(CHANGELOG_COLLECTION_NAME) - .count(changeQuery("test5")); - assertEquals(1, change5); long changeAll = mongoDatabase.getCollection(CHANGELOG_COLLECTION_NAME) .count(new Document().append(ChangeEntry.KEY_AUTHOR, "testuser")); - assertEquals(12, changeAll); + assertEquals(9, changeAll); } @Test @@ -129,16 +124,6 @@ public void shouldUsePreConfiguredMongoTemplate() throws Exception { verify(mt).getCollectionNames(); } - @Test - public void shouldUsePreConfiguredJongo() throws Exception { - Jongo jongo = mock(Jongo.class); - when(changeEntryDao.acquireProcessLock()).thenReturn(true); - when(jongo.getDatabase()).thenReturn(null); - mongobee.setJongo(jongo); - mongobee.afterPropertiesSet(); - verify(jongo).getDatabase(); - } - @Test public void shouldExecuteProcessWhenLockAcquired() throws Exception { // given @@ -180,6 +165,7 @@ public void shouldReturnExecutionStatusBasedOnDao() throws Exception { // given when(changeEntryDao.isProccessLockHeld()).thenReturn(true); + //when boolean inProgress = mongobee.isExecutionInProgress(); // then @@ -210,7 +196,5 @@ public void shouldReleaseLockWhenExceptionInMigration() throws Exception { @After public void cleanUp() { mongobee.setMongoTemplate(null); - mongobee.setJongo(null); } - } diff --git a/src/test/java/com/github/mongobeej/test/changelogs/AnotherMongobeeTestResource.java b/src/test/java/com/github/mongobeej/test/changelogs/AnotherMongobeeTestResource.java index d6465bf..560c1be 100644 --- a/src/test/java/com/github/mongobeej/test/changelogs/AnotherMongobeeTestResource.java +++ b/src/test/java/com/github/mongobeej/test/changelogs/AnotherMongobeeTestResource.java @@ -2,9 +2,8 @@ import com.github.mongobeej.changeset.ChangeLog; import com.github.mongobeej.changeset.ChangeSet; -import com.mongodb.DB; import com.mongodb.client.MongoDatabase; -import org.jongo.Jongo; +import org.springframework.data.mongodb.core.MongoTemplate; /** * @author lstolowski @@ -23,22 +22,12 @@ public void testChangeSet2() { System.out.println("invoked B2"); } - @ChangeSet(author = "testuser", id = "Btest3", order = "03") - public void testChangeSet3(DB db) { - System.out.println("invoked B3 with db=" + db.toString()); + @ChangeSet(author = "testuser", id = "Btest5", order = "03", runAlways = true) + public void testChangeSetWithAlways(MongoTemplate mongoTemplate) { + System.out.println("invoked B5 with always + mongoTemplate=" + mongoTemplate.toString()); } - @ChangeSet(author = "testuser", id = "Btest4", order = "04") - public void testChangeSet4(Jongo jongo) { - System.out.println("invoked B4 with jongo=" + jongo.toString()); - } - - @ChangeSet(author = "testuser", id = "Btest5", order = "05", runAlways = true) - public void testChangeSetWithAlways(Jongo jongo) { - System.out.println("invoked B5 with always + jongo=" + jongo.getDatabase()); - } - - @ChangeSet(author = "testuser", id = "Btest6", order = "06") + @ChangeSet(author = "testuser", id = "Btest6", order = "04") public void testChangeSet6(MongoDatabase mongoDatabase) { System.out.println("invoked B6 with db=" + mongoDatabase.toString()); } diff --git a/src/test/java/com/github/mongobeej/test/changelogs/MongobeeTestResource.java b/src/test/java/com/github/mongobeej/test/changelogs/MongobeeTestResource.java index 634ed01..8f850f5 100644 --- a/src/test/java/com/github/mongobeej/test/changelogs/MongobeeTestResource.java +++ b/src/test/java/com/github/mongobeej/test/changelogs/MongobeeTestResource.java @@ -2,9 +2,8 @@ import com.github.mongobeej.changeset.ChangeLog; import com.github.mongobeej.changeset.ChangeSet; -import com.mongodb.DB; import com.mongodb.client.MongoDatabase; -import org.jongo.Jongo; +import org.springframework.data.mongodb.core.MongoTemplate; /** * @author lstolowski @@ -15,37 +14,22 @@ public class MongobeeTestResource { @ChangeSet(author = "testuser", id = "test1", order = "01") public void testChangeSet() { - System.out.println("invoked 1"); - } @ChangeSet(author = "testuser", id = "test2", order = "02") public void testChangeSet2() { - System.out.println("invoked 2"); - } @ChangeSet(author = "testuser", id = "test3", order = "03") - public void testChangeSet3(DB db) { - - System.out.println("invoked 3 with db=" + db.toString()); - + public void testChangeSet4(MongoTemplate mongoTemplate) { + System.out.println("invoked 4 with mongoTemplate=" + mongoTemplate.toString()); } @ChangeSet(author = "testuser", id = "test4", order = "04") - public void testChangeSet4(Jongo jongo) { - - System.out.println("invoked 4 with jongo=" + jongo.toString()); - - } - - @ChangeSet(author = "testuser", id = "test5", order = "05") public void testChangeSet5(MongoDatabase mongoDatabase) { - System.out.println("invoked 5 with mongoDatabase=" + mongoDatabase.toString()); - } } diff --git a/src/test/java/com/github/mongobeej/utils/ChangeServiceTest.java b/src/test/java/com/github/mongobeej/utils/ChangeServiceTest.java index 14e173f..853d572 100644 --- a/src/test/java/com/github/mongobeej/utils/ChangeServiceTest.java +++ b/src/test/java/com/github/mongobeej/utils/ChangeServiceTest.java @@ -35,7 +35,7 @@ public void shouldFindChangeSetMethods() throws MongobeeChangeSetException { List foundMethods = changeService.fetchChangeSets(MongobeeTestResource.class); // then - assertTrue(foundMethods != null && foundMethods.size() == 5); + assertTrue(foundMethods != null && foundMethods.size() == 4); } @Test @@ -44,7 +44,7 @@ public void shouldFindAnotherChangeSetMethods() throws MongobeeChangeSetExceptio List foundMethods = changeService.fetchChangeSets(AnotherMongobeeTestResource.class); // then - assertTrue(foundMethods != null && foundMethods.size() == 6); + assertTrue(foundMethods != null && foundMethods.size() == 4); }