### Question:
RestrictConflictMergeBehaviourImpl implements MergeBehaviour<SyncObject> { @Override public MergeResult<SyncObject> resolveDiff(Class<? extends SyncObject> clazz, SyncObject local, SyncObject foreign) { return revolveConflict(local, foreign); }  @Override MergeResult<SyncObject> resolveDiff(Class<? extends SyncObject> clazz, SyncObject local, SyncObject foreign);  }### Answer:
@Test public void resolveDiff_shouldReturnSuccessAndChooseLocalIfOnlyLocalChanged() { SyncObject localObj = getSyncObject(SimpleObjectMother.createInstance(VALID_UUID, TEST_VALUE)); SyncObject foreignObj = getSyncObject(SimpleObjectMother.createInstance(VALID_UUID, TEST_VALID_HASHCODE_VALUE)); MergeResult actual = conflictMergeBehaviour.resolveDiff(SyncObject.class, localObj, foreignObj); Assert.assertTrue(actual instanceof MergeSuccess); Assert.assertEquals(MergeMessageEnum.LOCAL_SAVE_MESSAGE, actual.getMessage()); Assert.assertTrue(((MergeSuccess) actual).shouldUpdateLocal()); Assert.assertFalse(((MergeSuccess) actual).shouldUpdateForeign()); }
@Test public void resolveDiff_shouldReturnSuccessAndChooseForeignIfOnlyForeignChanged() { SyncObject localObj = getSyncObject(SimpleObjectMother.createInstance(VALID_UUID, TEST_VALID_HASHCODE_VALUE)); SyncObject foreignObj = getSyncObject(SimpleObjectMother.createInstance(VALID_UUID, TEST_VALUE_2)); MergeResult actual = conflictMergeBehaviour.resolveDiff(SyncObject.class, localObj, foreignObj); Assert.assertTrue(actual instanceof MergeSuccess); Assert.assertEquals(MergeMessageEnum.FOREIGN_SAVE_MESSAGE, actual.getMessage()); Assert.assertFalse(((MergeSuccess) actual).shouldUpdateLocal()); Assert.assertTrue(((MergeSuccess) actual).shouldUpdateForeign()); }
@Test public void resolveDiff_shouldReturnConflictWhenBothObjectsChanged() { SyncObject localObj = getSyncObject(SimpleObjectMother.createInstance(VALID_UUID, TEST_VALUE)); SyncObject foreignObj = getSyncObject(SimpleObjectMother.createInstance(VALID_UUID, TEST_VALUE_2)); MergeResult actual = conflictMergeBehaviour.resolveDiff(SyncObject.class, localObj, foreignObj); Assert.assertTrue(actual instanceof MergeConflict); Assert.assertEquals(MergeMessageEnum.CONFLICT, actual.getMessage()); }
@Test public void resolveDiff_shouldReturnSuccessAndChooseLocalIfParentHashcodeNotExist() { SyncObject localObj = getSyncObject(SimpleObjectMother.createInstance(INVALID_UUID, TEST_VALUE)); SyncObject foreignObj = getSyncObject(SimpleObjectMother.createInstance(INVALID_UUID, TEST_VALUE_2)); MergeResult actual = conflictMergeBehaviour.resolveDiff(SyncObject.class, localObj, foreignObj); Assert.assertTrue(actual instanceof MergeSuccess); Assert.assertEquals(MergeMessageEnum.LOCAL_SAVE_MESSAGE, actual.getMessage()); Assert.assertTrue(((MergeSuccess) actual).shouldUpdateLocal()); Assert.assertFalse(((MergeSuccess) actual).shouldUpdateForeign()); }