MigraMongoJMX { @ManagedOperation public String migrate() { return toJson(migraMongo.migrate()); } MigraMongoJMX(MigraMongo migraMongo); @ManagedOperation String migrate(); @ManagedOperation String migrateAsync(); @ManagedOperation String dryRun(); @ManagedOperation String status(String fromVersion); @ManagedOperation Boolean needsMigration(); @ManagedOperation String history(); @ManagedOperation void destroyLocks();  }
@Test public void shouldReturnCorrectJsonWithSimpleStatus() { when(migraMongo.migrate()).thenReturn(MigraMongoStatus.ok()); final String jsonStatus = migraMongoJMX.migrate(); final MigraMongoStatus status = new Gson().fromJson(jsonStatus, MigraMongoStatus.class); assertThat(status.migrationsApplied, hasSize(0)); assertThat(status.status, is(MigrationStatus.OK)); }
@Test public void shouldReturnCorrectJsonWhenMigrationsApplied() { final MigraMongoStatus migraMongoStatus = MigraMongoStatus.ok().addEntry(createMigrationEntry("3.0", "4.0")); when(migraMongo.migrate()).thenReturn(migraMongoStatus); final String jsonStatus = migraMongoJMX.migrate(); final MigraMongoStatus status = new Gson().fromJson(jsonStatus, MigraMongoStatus.class); assertThat(status, samePropertyValuesAs(migraMongoStatus)); }