| Chunk |
|---|
| Conflicting content |
|---|
import android.test.AndroidTestCase; <<<<<<< HEAD import java.util.Calendar; import java.util.Date; ======= import java.util.HashSet; import java.util.Set; >>>>>>> 395f022708642dd31a862439f0369918619dc27e import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; |
| Solution content |
|---|
import android.test.AndroidTestCase; import java.util.Calendar; import java.util.Date; import java.util.HashSet; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; |
| File |
|---|
| RealmObjectTest.java |
| Developer's decision |
|---|
| Concatenation |
| Kind of conflict |
|---|
| Import |
| Chunk |
|---|
| Conflicting content |
|---|
AllTypes object = testRealm.allObjects(AllTypes.class).first();
assertTrue(methodWrongThread(false));
}
<<<<<<< HEAD
public void testDateType() {
long testDatesNotValid[] = {Integer.MIN_VALUE/1000, Integer.MAX_VALUE/1000}; // 32 bit system
long testDatesValid[] = {-1000, 0, 1000};
long testDatesLoosePrecision[] = {1, 1001}; // 32 bit system
// test valid dates
testRealm.beginTransaction();
for (long value : testDatesValid) {
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(new Date(value));
}
testRealm.commitTransaction();
int i = 0;
for (AllTypes allTypes : testRealm.allObjects(AllTypes.class)) {
assertEquals("Item " + i, new Date(testDatesValid[i]), allTypes.getColumnDate());
i++;
}
// test valid dates but with precision lost
testRealm.beginTransaction();
testRealm.clear(AllTypes.class);
for (long value : testDatesLoosePrecision) {
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(new Date(value));
}
testRealm.commitTransaction();
i = 0;
for (AllTypes allTypes : testRealm.allObjects(AllTypes.class)) {
assertFalse("Item " + i, new Date(testDatesLoosePrecision[i]) == allTypes.getColumnDate());
assertEquals("Item " + i, new Date(1000*(testDatesLoosePrecision[i]/1000)), allTypes.getColumnDate());
i++;
}
// test invalid dates
testRealm.beginTransaction();
testRealm.clear(AllTypes.class);
for (long value : testDatesNotValid) {
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(new Date(value));
}
testRealm.commitTransaction();
RealmResults |
| Solution content |
|---|
assertTrue(methodWrongThread(false));
}
public void testDateType() {
long testDatesNotValid[] = {Long.MIN_VALUE, Long.MAX_VALUE};
long testDatesValid[] = {-1000, 0, 1000};
long testDatesLoosePrecision[] = {1, 1001};
// test valid dates
testRealm.beginTransaction();
testRealm.clear(AllTypes.class);
for (long value : testDatesValid) {
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(new Date(value));
}
testRealm.commitTransaction();
int i = 0;
for (AllTypes allTypes : testRealm.allObjects(AllTypes.class)) {
assertEquals("Item " + i, new Date(testDatesValid[i]), allTypes.getColumnDate());
i++;
}
// test valid dates but with precision lost
testRealm.beginTransaction();
testRealm.clear(AllTypes.class);
for (long value : testDatesLoosePrecision) {
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(new Date(value));
}
testRealm.commitTransaction();
i = 0;
for (AllTypes allTypes : testRealm.allObjects(AllTypes.class)) {
assertFalse("Item " + i, new Date(testDatesLoosePrecision[i]) == allTypes.getColumnDate());
assertEquals("Item " + i, new Date(1000*(testDatesLoosePrecision[i]/1000)), allTypes.getColumnDate());
i++;
}
// test invalid dates
for (long value : testDatesNotValid) {
try {
testRealm.beginTransaction();
testRealm.clear(AllTypes.class);
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(new Date(value));
testRealm.commitTransaction();
fail();
} catch (IllegalArgumentException ignored) { testRealm.cancelTransaction(); }
}
}
private void addDate(int year, int month, int dayOfMonth) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
// Create the Date object
Date date = cal.getTime();
testRealm.beginTransaction();
testRealm.clear(AllTypes.class);
AllTypes allTypes = testRealm.createObject(AllTypes.class);
allTypes.setColumnDate(date);
testRealm.commitTransaction();
AllTypes object = testRealm.allObjects(AllTypes.class).first();
assertEquals(1000*(date.getTime()/1000), 1000*(object.getColumnDate().getTime()/1000)); // Realm does not support millisec precision
}
public void testDate() {
// Too old
for (int i = 0; i < 2; i++) {
try {
addDate(1900 + i, 1, 1);
fail();
} catch (IllegalArgumentException ignored) {
testRealm.cancelTransaction();
}
}
// Fine
for (int i = 2; i < 10; i++) {
addDate(1900 + i, 1, 1);
}
// Too far in the future
for (int i = 0; i < 2; i++) {
try {
addDate(2038 + i, 1, 20);
fail();
} catch (IllegalArgumentException ignored) {
testRealm.cancelTransaction();
}
}
}
// Annotation processor honors common naming conventions
// We check if setters and getters are generated and working
public void testNamingConvention() {
Realm realm = Realm.getInstance(getContext());
realm.beginTransaction();
realm.clear(AnnotationNameConventions.class);
AnnotationNameConventions anc1 = realm.createObject(AnnotationNameConventions.class);
anc1.setHasObject(true);
anc1.setId_object(1);
anc1.setmObject(2);
anc1.setObject_id(3);
anc1.setObject(true);
realm.commitTransaction();
AnnotationNameConventions anc2 = realm.allObjects(AnnotationNameConventions.class).first();
assertTrue(anc2.isHasObject());
assertEquals(1, anc2.getId_object());
assertEquals(2, anc2.getmObject());
assertEquals(3, anc2.getObject_id());
assertTrue(anc2.isObject());
}
} |
| File |
|---|
| RealmObjectTest.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Comment |
| For statement |
| Method declaration |
| Method invocation |
| Method signature |
| Variable |