@Test public void testUpdateCachedEntityWithUpdatedPersonActorAndOriginalActorAndNoChanges() { authorStreamEntityDTOUpdaters.add(updater1); authorStreamEntityDTOUpdaters.add(updater2); final StreamEntityDTO actorEntity = new StreamEntityDTO(); actorEntity.setType(EntityType.PERSON); actorEntity.setId(updatedPersonId); final StreamEntityDTO originalActorEntity = new StreamEntityDTO(); originalActorEntity.setType(EntityType.PERSON); originalActorEntity.setId(updatedPersonId); context.checking(new Expectations() { { allowing(activityDTO).getActor(); will(returnValue(actorEntity)); allowing(activityDTO).getOriginalActor(); will(returnValue(originalActorEntity)); oneOf(updater1).execute(actorEntity, personWithUpdatedInfo); will(returnValue(false)); oneOf(updater2).execute(actorEntity, personWithUpdatedInfo); will(returnValue(false)); oneOf(updater1).execute(originalActorEntity, personWithUpdatedInfo); will(returnValue(false)); oneOf(updater2).execute(originalActorEntity, personWithUpdatedInfo); will(returnValue(false)); } }); boolean result = sut.updateCachedEntity(activityDTO, personWithUpdatedInfo); assertFalse(result); context.assertIsSatisfied(); }
@Override protected Boolean updateCachedEntity(final ActivityDTO inActivityDTO, final Person inPerson) { boolean isUpdated = false; if (log.isTraceEnabled()) { log.trace("Looking at activity with id:" + inActivityDTO.getId() + " for personId: " + inPerson.getId()); } if (inActivityDTO.getActor() != null && inActivityDTO.getActor().getType() == EntityType.PERSON && inActivityDTO.getActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getActor(), inPerson); } } if (inActivityDTO.getOriginalActor() != null && inActivityDTO.getOriginalActor().getType() == EntityType.PERSON && inActivityDTO.getOriginalActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is original actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getOriginalActor(), inPerson); } } return isUpdated; }
UpdateAuthorInfoInCachedActivities extends UpdateCachedItemsByIds<ActivityDTO, Person> { @Override protected Boolean updateCachedEntity(final ActivityDTO inActivityDTO, final Person inPerson) { boolean isUpdated = false; if (log.isTraceEnabled()) { log.trace("Looking at activity with id:" + inActivityDTO.getId() + " for personId: " + inPerson.getId()); } if (inActivityDTO.getActor() != null && inActivityDTO.getActor().getType() == EntityType.PERSON && inActivityDTO.getActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getActor(), inPerson); } } if (inActivityDTO.getOriginalActor() != null && inActivityDTO.getOriginalActor().getType() == EntityType.PERSON && inActivityDTO.getOriginalActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is original actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getOriginalActor(), inPerson); } } return isUpdated; } }
UpdateAuthorInfoInCachedActivities extends UpdateCachedItemsByIds<ActivityDTO, Person> { @Override protected Boolean updateCachedEntity(final ActivityDTO inActivityDTO, final Person inPerson) { boolean isUpdated = false; if (log.isTraceEnabled()) { log.trace("Looking at activity with id:" + inActivityDTO.getId() + " for personId: " + inPerson.getId()); } if (inActivityDTO.getActor() != null && inActivityDTO.getActor().getType() == EntityType.PERSON && inActivityDTO.getActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getActor(), inPerson); } } if (inActivityDTO.getOriginalActor() != null && inActivityDTO.getOriginalActor().getType() == EntityType.PERSON && inActivityDTO.getOriginalActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is original actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getOriginalActor(), inPerson); } } return isUpdated; } UpdateAuthorInfoInCachedActivities(final Integer inBatchSize,
            final List<UpdateStreamEntityDTOFromPerson> inAuthorStreamEntityDTOUpdaters); }
UpdateAuthorInfoInCachedActivities extends UpdateCachedItemsByIds<ActivityDTO, Person> { @Override protected Boolean updateCachedEntity(final ActivityDTO inActivityDTO, final Person inPerson) { boolean isUpdated = false; if (log.isTraceEnabled()) { log.trace("Looking at activity with id:" + inActivityDTO.getId() + " for personId: " + inPerson.getId()); } if (inActivityDTO.getActor() != null && inActivityDTO.getActor().getType() == EntityType.PERSON && inActivityDTO.getActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getActor(), inPerson); } } if (inActivityDTO.getOriginalActor() != null && inActivityDTO.getOriginalActor().getType() == EntityType.PERSON && inActivityDTO.getOriginalActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is original actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getOriginalActor(), inPerson); } } return isUpdated; } UpdateAuthorInfoInCachedActivities(final Integer inBatchSize,
            final List<UpdateStreamEntityDTOFromPerson> inAuthorStreamEntityDTOUpdaters);  }
UpdateAuthorInfoInCachedActivities extends UpdateCachedItemsByIds<ActivityDTO, Person> { @Override protected Boolean updateCachedEntity(final ActivityDTO inActivityDTO, final Person inPerson) { boolean isUpdated = false; if (log.isTraceEnabled()) { log.trace("Looking at activity with id:" + inActivityDTO.getId() + " for personId: " + inPerson.getId()); } if (inActivityDTO.getActor() != null && inActivityDTO.getActor().getType() == EntityType.PERSON && inActivityDTO.getActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getActor(), inPerson); } } if (inActivityDTO.getOriginalActor() != null && inActivityDTO.getOriginalActor().getType() == EntityType.PERSON && inActivityDTO.getOriginalActor().getId() == inPerson.getId()) { if (log.isTraceEnabled()) { log.trace("Person with id:" + inPerson.getId() + " is original actor of activity with id:" + inActivityDTO.getId() + ". Updating it."); } for (UpdateStreamEntityDTOFromPerson updater : authorStreamEntityDTOUpdaters) { isUpdated |= updater.execute(inActivityDTO.getOriginalActor(), inPerson); } } return isUpdated; } UpdateAuthorInfoInCachedActivities(final Integer inBatchSize,
            final List<UpdateStreamEntityDTOFromPerson> inAuthorStreamEntityDTOUpdaters);   }