Exemple #1
0
 @Test
 public void shouldDoNothingIfDatabaseHasAllMigrations() {
   mockery.checking(
       new Expectations() {
         {
           one(provider).getAppliedMigrations();
           will(returnValue(Arrays.asList("second", "first")));
         }
       });
   Migrations migrationsToApply = migrator.getMigrationsToApply();
   assertThat(migrationsToApply.size(), is(equalTo(0)));
   mockery.assertIsSatisfied();
 }
Exemple #2
0
 @Test
 public void shouldReturnNonExecutedMigrationsIfThereAreAnyPending() {
   mockery.checking(
       new Expectations() {
         {
           one(provider).getAppliedMigrations();
           will(returnValue(Arrays.asList("first")));
         }
       });
   Migrations migrationsToApply = migrator.getMigrationsToApply();
   assertThat(migrationsToApply.size(), is(equalTo(1)));
   assertThat(migrationsToApply.getAll().iterator().next(), is(equalTo(second)));
   mockery.assertIsSatisfied();
 }
Exemple #3
0
  @Test
  public void verify() throws SQLException {
    migrator.migrate();
    DBCollection collection = migrator.getDb().getCollection("classesIDs");
    long count = 0;
    DateTime begin = DateTime.now();
    try (Connection connection = migrator.getConnection();
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select id from classes")) {
      while (resultSet.next()) {
        count++;
        long id = resultSet.getLong("id");
        ObjectId objectId = migrator.lookupId("classes", id);

        JavadocClassCriteria criteria = new JavadocClassCriteria(ds);
        criteria.id(objectId);
        Assert.assertNotNull(
            criteria.query().get(), String.format("Looking for %d => %s", id, objectId));
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage(), e);
    }
  }
 public boolean downgrade(JSONObject state, StateStore stateStore, Migrator migrator)
     throws JSONException {
   return migrator.removeProperty(state, "customBar");
 }
    public boolean upgrade(JSONObject state, StateStore stateStore, Migrator migrator)
        throws JSONException {
      JSONObject properties = (JSONObject) state.get(MapEntityStore.JSONKeys.properties.name());

      return migrator.addProperty(state, "customBar", "Hello " + properties.getString("bar"));
    }