@Test public void testExecuteWhenSharedResourceDNE() { final String uniqueKey = "http: final StreamScope sharedResourceStreamScope = null; final SharedResourceRequest request = new SharedResourceRequest(uniqueKey, null); context.checking(new Expectations() { { oneOf(getResourceStreamScopeByKeyMapper).execute(with(uniqueKey)); will(returnValue(sharedResourceStreamScope)); } }); SharedResourceDTO result = sut.execute(request); assertNull(result.getStreamScopeId()); assertEquals(0, result.getLikeCount()); assertEquals(0, result.getShareCount()); assertNull(result.getLikersSample()); assertNull(result.getSharersSample()); assertEquals(uniqueKey, result.getKey()); context.assertIsSatisfied(); }
@Override public SharedResourceDTO execute(final SharedResourceRequest inRequest) { SharedResourceDTO dto = new SharedResourceDTO(); dto.setKey(inRequest.getUniqueKey()); log.info("Looking for the stream scope for shared resource with uniqueKey " + inRequest.getUniqueKey()); StreamScope sharedResourceStreamScope = getResourceStreamScopeByKeyMapper.execute(inRequest.getUniqueKey()); if (sharedResourceStreamScope == null) { log.info("Couldn't find the stream scope for shared resource with unique key " + inRequest.getUniqueKey() + " - must not exist. Cache as such."); dto.setStreamScopeId(null); dto.setIsLiked(false); return dto; } dto.setStreamScopeId(sharedResourceStreamScope.getId()); inRequest.setSharedResourceId(sharedResourceStreamScope.getDestinationEntityId()); log.info("Found the shared resource for unique key " + inRequest.getUniqueKey() + " - looking for lists of people ids that liked and shared it."); List<Long> sharedPersonIds = getPeopleThatSharedResourceMapper.execute(inRequest); List<Long> likedPersonIds = getPeopleThatLikedResourceMapper.execute(inRequest); if (sharedPersonIds == null) { sharedPersonIds = new ArrayList<Long>(); } dto.setLikerPersonIds(likedPersonIds); if (likedPersonIds == null) { likedPersonIds = new ArrayList<Long>(); } dto.setSharerPersonIds(sharedPersonIds); return dto; }
GetSharedResourcePropertiesMapper extends BaseArgDomainMapper<SharedResourceRequest, SharedResourceDTO> { @Override public SharedResourceDTO execute(final SharedResourceRequest inRequest) { SharedResourceDTO dto = new SharedResourceDTO(); dto.setKey(inRequest.getUniqueKey()); log.info("Looking for the stream scope for shared resource with uniqueKey " + inRequest.getUniqueKey()); StreamScope sharedResourceStreamScope = getResourceStreamScopeByKeyMapper.execute(inRequest.getUniqueKey()); if (sharedResourceStreamScope == null) { log.info("Couldn't find the stream scope for shared resource with unique key " + inRequest.getUniqueKey() + " - must not exist. Cache as such."); dto.setStreamScopeId(null); dto.setIsLiked(false); return dto; } dto.setStreamScopeId(sharedResourceStreamScope.getId()); inRequest.setSharedResourceId(sharedResourceStreamScope.getDestinationEntityId()); log.info("Found the shared resource for unique key " + inRequest.getUniqueKey() + " - looking for lists of people ids that liked and shared it."); List<Long> sharedPersonIds = getPeopleThatSharedResourceMapper.execute(inRequest); List<Long> likedPersonIds = getPeopleThatLikedResourceMapper.execute(inRequest); if (sharedPersonIds == null) { sharedPersonIds = new ArrayList<Long>(); } dto.setLikerPersonIds(likedPersonIds); if (likedPersonIds == null) { likedPersonIds = new ArrayList<Long>(); } dto.setSharerPersonIds(sharedPersonIds); return dto; } }
GetSharedResourcePropertiesMapper extends BaseArgDomainMapper<SharedResourceRequest, SharedResourceDTO> { @Override public SharedResourceDTO execute(final SharedResourceRequest inRequest) { SharedResourceDTO dto = new SharedResourceDTO(); dto.setKey(inRequest.getUniqueKey()); log.info("Looking for the stream scope for shared resource with uniqueKey " + inRequest.getUniqueKey()); StreamScope sharedResourceStreamScope = getResourceStreamScopeByKeyMapper.execute(inRequest.getUniqueKey()); if (sharedResourceStreamScope == null) { log.info("Couldn't find the stream scope for shared resource with unique key " + inRequest.getUniqueKey() + " - must not exist. Cache as such."); dto.setStreamScopeId(null); dto.setIsLiked(false); return dto; } dto.setStreamScopeId(sharedResourceStreamScope.getId()); inRequest.setSharedResourceId(sharedResourceStreamScope.getDestinationEntityId()); log.info("Found the shared resource for unique key " + inRequest.getUniqueKey() + " - looking for lists of people ids that liked and shared it."); List<Long> sharedPersonIds = getPeopleThatSharedResourceMapper.execute(inRequest); List<Long> likedPersonIds = getPeopleThatLikedResourceMapper.execute(inRequest); if (sharedPersonIds == null) { sharedPersonIds = new ArrayList<Long>(); } dto.setLikerPersonIds(likedPersonIds); if (likedPersonIds == null) { likedPersonIds = new ArrayList<Long>(); } dto.setSharerPersonIds(sharedPersonIds); return dto; } GetSharedResourcePropertiesMapper(
            final DomainMapper<String, StreamScope> inGetResourceStreamScopeByKeyMapper,
            final DomainMapper<SharedResourceRequest, List<Long>> inGetPeopleThatSharedResourceMapper,
            final DomainMapper<SharedResourceRequest, List<Long>> inGetPeopleThatLikedResourceMapper); }
GetSharedResourcePropertiesMapper extends BaseArgDomainMapper<SharedResourceRequest, SharedResourceDTO> { @Override public SharedResourceDTO execute(final SharedResourceRequest inRequest) { SharedResourceDTO dto = new SharedResourceDTO(); dto.setKey(inRequest.getUniqueKey()); log.info("Looking for the stream scope for shared resource with uniqueKey " + inRequest.getUniqueKey()); StreamScope sharedResourceStreamScope = getResourceStreamScopeByKeyMapper.execute(inRequest.getUniqueKey()); if (sharedResourceStreamScope == null) { log.info("Couldn't find the stream scope for shared resource with unique key " + inRequest.getUniqueKey() + " - must not exist. Cache as such."); dto.setStreamScopeId(null); dto.setIsLiked(false); return dto; } dto.setStreamScopeId(sharedResourceStreamScope.getId()); inRequest.setSharedResourceId(sharedResourceStreamScope.getDestinationEntityId()); log.info("Found the shared resource for unique key " + inRequest.getUniqueKey() + " - looking for lists of people ids that liked and shared it."); List<Long> sharedPersonIds = getPeopleThatSharedResourceMapper.execute(inRequest); List<Long> likedPersonIds = getPeopleThatLikedResourceMapper.execute(inRequest); if (sharedPersonIds == null) { sharedPersonIds = new ArrayList<Long>(); } dto.setLikerPersonIds(likedPersonIds); if (likedPersonIds == null) { likedPersonIds = new ArrayList<Long>(); } dto.setSharerPersonIds(sharedPersonIds); return dto; } GetSharedResourcePropertiesMapper(
            final DomainMapper<String, StreamScope> inGetResourceStreamScopeByKeyMapper,
            final DomainMapper<SharedResourceRequest, List<Long>> inGetPeopleThatSharedResourceMapper,
            final DomainMapper<SharedResourceRequest, List<Long>> inGetPeopleThatLikedResourceMapper); @Override SharedResourceDTO execute(final SharedResourceRequest inRequest); }
GetSharedResourcePropertiesMapper extends BaseArgDomainMapper<SharedResourceRequest, SharedResourceDTO> { @Override public SharedResourceDTO execute(final SharedResourceRequest inRequest) { SharedResourceDTO dto = new SharedResourceDTO(); dto.setKey(inRequest.getUniqueKey()); log.info("Looking for the stream scope for shared resource with uniqueKey " + inRequest.getUniqueKey()); StreamScope sharedResourceStreamScope = getResourceStreamScopeByKeyMapper.execute(inRequest.getUniqueKey()); if (sharedResourceStreamScope == null) { log.info("Couldn't find the stream scope for shared resource with unique key " + inRequest.getUniqueKey() + " - must not exist. Cache as such."); dto.setStreamScopeId(null); dto.setIsLiked(false); return dto; } dto.setStreamScopeId(sharedResourceStreamScope.getId()); inRequest.setSharedResourceId(sharedResourceStreamScope.getDestinationEntityId()); log.info("Found the shared resource for unique key " + inRequest.getUniqueKey() + " - looking for lists of people ids that liked and shared it."); List<Long> sharedPersonIds = getPeopleThatSharedResourceMapper.execute(inRequest); List<Long> likedPersonIds = getPeopleThatLikedResourceMapper.execute(inRequest); if (sharedPersonIds == null) { sharedPersonIds = new ArrayList<Long>(); } dto.setLikerPersonIds(likedPersonIds); if (likedPersonIds == null) { likedPersonIds = new ArrayList<Long>(); } dto.setSharerPersonIds(sharedPersonIds); return dto; } GetSharedResourcePropertiesMapper(
            final DomainMapper<String, StreamScope> inGetResourceStreamScopeByKeyMapper,
            final DomainMapper<SharedResourceRequest, List<Long>> inGetPeopleThatSharedResourceMapper,
            final DomainMapper<SharedResourceRequest, List<Long>> inGetPeopleThatLikedResourceMapper); @Override SharedResourceDTO execute(final SharedResourceRequest inRequest);  }