Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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);
    }
  }
Exemplo n.º 4
0
 public boolean downgrade(JSONObject state, StateStore stateStore, Migrator migrator)
     throws JSONException {
   return migrator.removeProperty(state, "customBar");
 }
Exemplo n.º 5
0
    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"));
    }