Skip to content

Commit

Permalink
Readdded AllTypesRealmProxy unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmelchior committed Jun 2, 2015
1 parent b454011 commit 8e1dd5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RealmProcessorTest {
private JavaFileObject simpleModel = JavaFileObjects.forResource("some/test/Simple.java");
private JavaFileObject simpleProxy = JavaFileObjects.forResource("io/realm/SimpleRealmProxy.java");
private JavaFileObject allTypesModel = JavaFileObjects.forResource("some/test/AllTypes.java");
private JavaFileObject allTypesProxy = JavaFileObjects.forResource("io/realm/AllTypesRealmProxy.java");
private JavaFileObject allTypesDefaultModule = JavaFileObjects.forResource("io/realm/RealmDefaultModule.java");
private JavaFileObject allTypesDefaultMediator = JavaFileObjects.forResource("io/realm/RealmDefaultModuleMediator.java");
private JavaFileObject booleansModel = JavaFileObjects.forResource("some/test/Booleans.java");
Expand Down Expand Up @@ -110,7 +111,7 @@ public void compareProcessedAllTypesFile() throws Exception {
.processedWith(new RealmProcessor())
.compilesWithoutError()
.and()
.generatesSources(allTypesDefaultMediator, allTypesDefaultModule, allTypesDefaultMediator);
.generatesSources(allTypesProxy, allTypesDefaultMediator, allTypesDefaultModule, allTypesDefaultMediator);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void setColumnRealmList(RealmList<AllTypes> value) {
}

public static Table initTable(ImplicitTransaction transaction) {
if(!transaction.hasTable("class_AllTypes")) {
if (!transaction.hasTable("class_AllTypes")) {
Table table = transaction.getTable("class_AllTypes");
table.addColumn(ColumnType.STRING, "columnString");
table.addColumn(ColumnType.INTEGER, "columnLong");
Expand All @@ -200,11 +200,9 @@ public static Table initTable(ImplicitTransaction transaction) {
public static void validateTable(ImplicitTransaction transaction) {
if (transaction.hasTable("class_AllTypes")) {
Table table = transaction.getTable("class_AllTypes");

if(table.getColumnCount() != 9) {
if (table.getColumnCount() != 9) {
throw new RealmMigrationNeededException(transaction.getPath(), "Field count does not match - expected 9 but was " + table.getColumnCount());
}

Map<String, ColumnType> columnTypes = new HashMap<String, ColumnType>();
for (long i = 0; i < 9; i++) {
columnTypes.put(table.getColumnName(i), table.getColumnType(i));
Expand Down Expand Up @@ -285,12 +283,9 @@ public static void validateTable(ImplicitTransaction transaction) {
if (!transaction.hasTable("class_AllTypes")) {
throw new RealmMigrationNeededException(transaction.getPath(), "Missing class 'class_AllTypes' for field 'columnObject'");
}

Table table_7 = transaction.getTable("class_AllTypes");
if (!table.getLinkTarget(INDEX_COLUMNOBJECT).equals(table_7)) {
throw new RealmMigrationNeededException(transaction.getPath(), "Invalid RealmObject for field 'columnObject': '" +
table.getLinkTarget(INDEX_COLUMNOBJECT).getName() + "' - was '" +
table_7.getName() + "'");
if (!table.getLinkTarget(INDEX_COLUMNOBJECT).hasSameSchema(table_7)) {
throw new RealmMigrationNeededException(transaction.getPath(), "Invalid RealmObject for field 'columnObject': '" + table.getLinkTarget(INDEX_COLUMNOBJECT).getName() + "' expected - was '" + table_7.getName() + "'");

This comment has been minimized.

Copy link
@emanuelez

emanuelez Jun 3, 2015

Contributor

Long lines. Let's stick to 120

This comment has been minimized.

Copy link
@cmelchior

cmelchior Jun 3, 2015

Author Contributor

Its a generated class?

This comment has been minimized.

Copy link
@emanuelez

emanuelez Jun 3, 2015

Contributor

Yeah ok... that's alright :)

}
if (!columnTypes.containsKey("columnRealmList")) {
throw new RealmMigrationNeededException(transaction.getPath(), "Missing field 'columnRealmList'");
Expand All @@ -302,10 +297,8 @@ public static void validateTable(ImplicitTransaction transaction) {
throw new RealmMigrationNeededException(transaction.getPath(), "Missing class 'class_AllTypes' for field 'columnRealmList'");
}
Table table_8 = transaction.getTable("class_AllTypes");
if (!table.getLinkTarget(INDEX_COLUMNREALMLIST).equals(table_8)) {
throw new RealmMigrationNeededException(transaction.getPath(), "Invalid RealmList for field 'columnRealmList'. '" +
table.getLinkTarget(INDEX_COLUMNREALMLIST).getName() + "' expected - was '"
table_8.getName() + "'");
if (!table.getLinkTarget(INDEX_COLUMNREALMLIST).hasSameSchema(table_8)) {
throw new RealmMigrationNeededException(transaction.getPath(), "Invalid RealmList type for field 'columnRealmList': '" + table.getLinkTarget(INDEX_COLUMNREALMLIST).getName() + "' expected - was '" + table_8.getName() + "'");
}
} else {
throw new RealmMigrationNeededException(transaction.getPath(), "The AllTypes class is missing from the schema for this Realm.");
Expand Down Expand Up @@ -608,5 +601,4 @@ public boolean equals(Object o) {
return true;
}

}

}

0 comments on commit 8e1dd5b

Please sign in to comment.