@Test public void test() { final List<Long> personIdsUsingTheme = new ArrayList<Long>(Arrays.asList(4L)); context.checking(new Expectations() { { oneOf(findByIdMapper).execute(with(any(FindByIdRequest.class))); will(returnValue(theme)); allowing(theme).getUUID(); will(returnValue(themeUuid)); oneOf(getPeopleIdsUsingTheme).execute(themeId); will(returnValue(personIdsUsingTheme)); oneOf(deleteThemeMapper).execute(themeId); } }); TaskHandlerActionContext<ActionContext> actionContext = TestContextCreator .createTaskHandlerAsyncContext(themeId); List<UserActionRequest> queuedActions = actionContext.getUserActionRequests(); sut.execute(actionContext); context.assertIsSatisfied(); assertEquals(1, queuedActions.size()); assertTrue(deleteCacheKeysActionName.equals(queuedActions.get(0).getActionKey())); }
@Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long themeId = (Long) inActionContext.getActionContext().getParams(); Theme theme = findByIdMapper.execute(new FindByIdRequest("Theme", themeId)); String themeUuid = theme.getUUID(); HashSet<String> cacheKeysToDelete = new HashSet<String>(Arrays.asList(CacheKeys.THEME_CSS_BY_UUID + themeUuid, CacheKeys.THEME_HASH_BY_UUID + themeUuid)); Collection<Long> personIds = getPeopleIdsUsingTheme.execute(themeId); for (Long id : personIds) { cacheKeysToDelete.add(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + id); } inActionContext.getUserActionRequests().add( new UserActionRequest(deleteCacheKeysActionName, null, cacheKeysToDelete)); deleteThemeMapper.execute(themeId); return null; }
DeleteThemeExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long themeId = (Long) inActionContext.getActionContext().getParams(); Theme theme = findByIdMapper.execute(new FindByIdRequest("Theme", themeId)); String themeUuid = theme.getUUID(); HashSet<String> cacheKeysToDelete = new HashSet<String>(Arrays.asList(CacheKeys.THEME_CSS_BY_UUID + themeUuid, CacheKeys.THEME_HASH_BY_UUID + themeUuid)); Collection<Long> personIds = getPeopleIdsUsingTheme.execute(themeId); for (Long id : personIds) { cacheKeysToDelete.add(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + id); } inActionContext.getUserActionRequests().add( new UserActionRequest(deleteCacheKeysActionName, null, cacheKeysToDelete)); deleteThemeMapper.execute(themeId); return null; } }
DeleteThemeExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long themeId = (Long) inActionContext.getActionContext().getParams(); Theme theme = findByIdMapper.execute(new FindByIdRequest("Theme", themeId)); String themeUuid = theme.getUUID(); HashSet<String> cacheKeysToDelete = new HashSet<String>(Arrays.asList(CacheKeys.THEME_CSS_BY_UUID + themeUuid, CacheKeys.THEME_HASH_BY_UUID + themeUuid)); Collection<Long> personIds = getPeopleIdsUsingTheme.execute(themeId); for (Long id : personIds) { cacheKeysToDelete.add(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + id); } inActionContext.getUserActionRequests().add( new UserActionRequest(deleteCacheKeysActionName, null, cacheKeysToDelete)); deleteThemeMapper.execute(themeId); return null; } DeleteThemeExecution(final DomainMapper<FindByIdRequest, Theme> inFindByIdMapper,
            final DomainMapper<Long, Void> inDeleteThemeMapper,
            final DomainMapper<Long, Collection<Long>> inGetPeopleIdsUsingTheme,
            final String inDeleteCacheKeysActionName); }
DeleteThemeExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long themeId = (Long) inActionContext.getActionContext().getParams(); Theme theme = findByIdMapper.execute(new FindByIdRequest("Theme", themeId)); String themeUuid = theme.getUUID(); HashSet<String> cacheKeysToDelete = new HashSet<String>(Arrays.asList(CacheKeys.THEME_CSS_BY_UUID + themeUuid, CacheKeys.THEME_HASH_BY_UUID + themeUuid)); Collection<Long> personIds = getPeopleIdsUsingTheme.execute(themeId); for (Long id : personIds) { cacheKeysToDelete.add(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + id); } inActionContext.getUserActionRequests().add( new UserActionRequest(deleteCacheKeysActionName, null, cacheKeysToDelete)); deleteThemeMapper.execute(themeId); return null; } DeleteThemeExecution(final DomainMapper<FindByIdRequest, Theme> inFindByIdMapper,
            final DomainMapper<Long, Void> inDeleteThemeMapper,
            final DomainMapper<Long, Collection<Long>> inGetPeopleIdsUsingTheme,
            final String inDeleteCacheKeysActionName); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext); }
DeleteThemeExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { Long themeId = (Long) inActionContext.getActionContext().getParams(); Theme theme = findByIdMapper.execute(new FindByIdRequest("Theme", themeId)); String themeUuid = theme.getUUID(); HashSet<String> cacheKeysToDelete = new HashSet<String>(Arrays.asList(CacheKeys.THEME_CSS_BY_UUID + themeUuid, CacheKeys.THEME_HASH_BY_UUID + themeUuid)); Collection<Long> personIds = getPeopleIdsUsingTheme.execute(themeId); for (Long id : personIds) { cacheKeysToDelete.add(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + id); } inActionContext.getUserActionRequests().add( new UserActionRequest(deleteCacheKeysActionName, null, cacheKeysToDelete)); deleteThemeMapper.execute(themeId); return null; } DeleteThemeExecution(final DomainMapper<FindByIdRequest, Theme> inFindByIdMapper,
            final DomainMapper<Long, Void> inDeleteThemeMapper,
            final DomainMapper<Long, Collection<Long>> inGetPeopleIdsUsingTheme,
            final String inDeleteCacheKeysActionName); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext);  }