Source:
public void shouldCreateHistoryForOneToOneRelationships() { Address address = new Address(); address.setStreet("Broadway"); House house = new House(); house.setName("A house"); house.setHouseNumber((short)12); house.setAddress(address); house.setUId(UUID.randomUUID()); house = houseDataService.create(house); final long firstAddressId = house.getAddress().getId(); List historyList = historyService.getHistoryForInstance(house, ASC_ID); assertNotNull(historyList); assertTrue(historyList.isEmpty()); house.setName("Second house"); house = houseDataService.update(house); Address secondAddress = new Address(); secondAddress.setStreet("Abbey Road"); house.setAddress(secondAddress); house.setHouseNumber((short)87); house.setUId(UUID.randomUUID()); house = houseDataService.update(house); secondAddress = house.getAddress(); final long secondAddressId = secondAddress.getId(); assertNotSame(firstAddressId, secondAddressId); secondAddress.setStreet("The Abbey Road"); addressDataService.update(secondAddress); historyList = historyService.getHistoryForInstance(house, ASC_ID); assertNotNull(historyList); assertEquals(2, historyList.size()); verifyHouseRecord(historyList.get(0), "A house", firstAddressId); final long firstVersionId = (long) PropertyUtil.safeGetProperty(historyList.get(0), ID_FIELD_NAME); verifyHouseRecord(historyList.get(1), "Second house", firstAddressId); historyList = historyService.getHistoryForInstance(address, ASC_ID); assertNotNull(historyList); assertEquals(0, historyList.size()); historyList = historyService.getHistoryForInstance(secondAddress, ASC_ID); assertNotNull(historyList); assertEquals(1, historyList.size()); assertEquals("Abbey Road", safeGetProperty(historyList.get(0), "street")); final long houseId = house.getId(); houseDataService.revertToHistoricalRevision(houseId, firstVersionId); house = houseDataService.findById(houseId); verifyHouse(house, "A house", "Broadway"); houseDataService.delete(house); }

Target:
public void shouldCreateHistoryForOneToOneRelationships() { Address address = new Address(); address.setStreet("Broadway"); House house = new House(); house.setName("A house"); house.setHouseNumber((short)12); house.setAddress(address); house.setUuid(UUID.randomUUID()); house = houseDataService.create(house); assertNotNull(house.getUuid()); final long firstAddressId = house.getAddress().getId(); List historyList = historyService.getHistoryForInstance(house, ASC_ID); assertNotNull(historyList); assertTrue(historyList.isEmpty()); house.setName("Second house"); house = houseDataService.update(house); assertNotNull(house.getUuid()); Address secondAddress = new Address(); secondAddress.setStreet("Abbey Road"); house.setAddress(secondAddress); house.setHouseNumber((short)87); house.setUuid(UUID.randomUUID()); house = houseDataService.update(house); secondAddress = house.getAddress(); final long secondAddressId = secondAddress.getId(); assertNotSame(firstAddressId, secondAddressId); secondAddress.setStreet("The Abbey Road"); addressDataService.update(secondAddress); historyList = historyService.getHistoryForInstance(house, ASC_ID); assertNotNull(historyList); assertEquals(2, historyList.size()); verifyHouseRecord(historyList.get(0), "A house", firstAddressId); final long firstVersionId = (long) PropertyUtil.safeGetProperty(historyList.get(0), ID_FIELD_NAME); verifyHouseRecord(historyList.get(1), "Second house", firstAddressId); historyList = historyService.getHistoryForInstance(address, ASC_ID); assertNotNull(historyList); assertEquals(0, historyList.size()); historyList = historyService.getHistoryForInstance(secondAddress, ASC_ID); assertNotNull(historyList); assertEquals(1, historyList.size()); assertEquals("Abbey Road", safeGetProperty(historyList.get(0), "street")); final long houseId = house.getId(); houseDataService.revertToHistoricalRevision(houseId, firstVersionId); house = houseDataService.findById(houseId); verifyHouse(house, "A house", "Broadway"); houseDataService.delete(house); }