@Test public final void testExeuctionWithWildCardKey() throws Exception { DeleteAppDataRequest currentRequest = new DeleteAppDataRequest(testApplicationId, testOpenSocialId, testAppDataStar); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, principalMock); context.checking(new Expectations() { { oneOf(jpaAppDataMapper).findOrCreateByPersonAndGadgetDefinitionIds(testApplicationId.longValue(), testOpenSocialId); will(returnValue(testAppData)); oneOf(testAppData).getValues(); will(returnValue(testAppDataValues)); oneOf(testAppData).getId(); will(returnValue(testAppDataId)); oneOf(jpaAppDataMapper).deleteAppDataValueByKey(testAppDataId, "key1"); oneOf(testAppData).getId(); will(returnValue(testAppDataId)); oneOf(jpaAppDataMapper).deleteAppDataValueByKey(testAppDataId, "key2"); oneOf(testAppData).getId(); will(returnValue(testAppDataId)); oneOf(jpaAppDataMapper).deleteAppDataValueByKey(testAppDataId, "key3"); oneOf(testAppData).getId(); will(returnValue(testAppDataId)); oneOf(jpaAppDataMapper).deleteAppDataValueByKey(testAppDataId, "key4"); oneOf(jpaAppDataMapper).flush(); oneOf(cache).delete(cacheKey); } }); assertNull(sut.execute(currentContext)); context.assertIsSatisfied(); }
@Override public Integer execute(final PrincipalActionContext inActionContext) throws ExecutionException { DeleteAppDataRequest inRequest = (DeleteAppDataRequest) inActionContext.getParams(); long applicationId = inRequest.getApplicationId(); String openSocialId = inRequest.getOpenSocialId(); Map<String, String> currentAppDataValues; try { AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, openSocialId); if (currentAppData != null) { currentAppDataValues = new HashMap<String, String>(currentAppData.getValues()); Iterator<String> appDataValueKeysIterator = inRequest.getAppDataValueKeys().iterator(); while (appDataValueKeysIterator.hasNext()) { final String appDataValueKey = appDataValueKeysIterator.next(); if (appDataValueKey == "*") { for (Entry<String, String> entry : currentAppDataValues.entrySet()) { mapper.deleteAppDataValueByKey(currentAppData.getId(), entry.getKey()); } break; } if (currentAppDataValues.containsKey(appDataValueKey)) { mapper.deleteAppDataValueByKey(currentAppData.getId(), appDataValueKey); } } mapper.flush(); log.info("Deleting the AppDataDTO cache for gadDef " + applicationId + ", open social id: " + openSocialId); cache.delete(CacheKeys.APPDATA_BY_GADGET_DEFINITION_ID_AND_UNDERSCORE_AND_PERSON_OPEN_SOCIAL_ID + applicationId + "_" + openSocialId); } } catch (Exception ex) { log.error("Error occurred deleting app data.", ex); throw new ExecutionException("Error occurred deleting app data.", ex); } return null; }
DeleteAppDataExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Integer execute(final PrincipalActionContext inActionContext) throws ExecutionException { DeleteAppDataRequest inRequest = (DeleteAppDataRequest) inActionContext.getParams(); long applicationId = inRequest.getApplicationId(); String openSocialId = inRequest.getOpenSocialId(); Map<String, String> currentAppDataValues; try { AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, openSocialId); if (currentAppData != null) { currentAppDataValues = new HashMap<String, String>(currentAppData.getValues()); Iterator<String> appDataValueKeysIterator = inRequest.getAppDataValueKeys().iterator(); while (appDataValueKeysIterator.hasNext()) { final String appDataValueKey = appDataValueKeysIterator.next(); if (appDataValueKey == "*") { for (Entry<String, String> entry : currentAppDataValues.entrySet()) { mapper.deleteAppDataValueByKey(currentAppData.getId(), entry.getKey()); } break; } if (currentAppDataValues.containsKey(appDataValueKey)) { mapper.deleteAppDataValueByKey(currentAppData.getId(), appDataValueKey); } } mapper.flush(); log.info("Deleting the AppDataDTO cache for gadDef " + applicationId + ", open social id: " + openSocialId); cache.delete(CacheKeys.APPDATA_BY_GADGET_DEFINITION_ID_AND_UNDERSCORE_AND_PERSON_OPEN_SOCIAL_ID + applicationId + "_" + openSocialId); } } catch (Exception ex) { log.error("Error occurred deleting app data.", ex); throw new ExecutionException("Error occurred deleting app data.", ex); } return null; } }
DeleteAppDataExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Integer execute(final PrincipalActionContext inActionContext) throws ExecutionException { DeleteAppDataRequest inRequest = (DeleteAppDataRequest) inActionContext.getParams(); long applicationId = inRequest.getApplicationId(); String openSocialId = inRequest.getOpenSocialId(); Map<String, String> currentAppDataValues; try { AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, openSocialId); if (currentAppData != null) { currentAppDataValues = new HashMap<String, String>(currentAppData.getValues()); Iterator<String> appDataValueKeysIterator = inRequest.getAppDataValueKeys().iterator(); while (appDataValueKeysIterator.hasNext()) { final String appDataValueKey = appDataValueKeysIterator.next(); if (appDataValueKey == "*") { for (Entry<String, String> entry : currentAppDataValues.entrySet()) { mapper.deleteAppDataValueByKey(currentAppData.getId(), entry.getKey()); } break; } if (currentAppDataValues.containsKey(appDataValueKey)) { mapper.deleteAppDataValueByKey(currentAppData.getId(), appDataValueKey); } } mapper.flush(); log.info("Deleting the AppDataDTO cache for gadDef " + applicationId + ", open social id: " + openSocialId); cache.delete(CacheKeys.APPDATA_BY_GADGET_DEFINITION_ID_AND_UNDERSCORE_AND_PERSON_OPEN_SOCIAL_ID + applicationId + "_" + openSocialId); } } catch (Exception ex) { log.error("Error occurred deleting app data.", ex); throw new ExecutionException("Error occurred deleting app data.", ex); } return null; } DeleteAppDataExecution(final AppDataMapper inMapper, final Cache inCache); }
DeleteAppDataExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Integer execute(final PrincipalActionContext inActionContext) throws ExecutionException { DeleteAppDataRequest inRequest = (DeleteAppDataRequest) inActionContext.getParams(); long applicationId = inRequest.getApplicationId(); String openSocialId = inRequest.getOpenSocialId(); Map<String, String> currentAppDataValues; try { AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, openSocialId); if (currentAppData != null) { currentAppDataValues = new HashMap<String, String>(currentAppData.getValues()); Iterator<String> appDataValueKeysIterator = inRequest.getAppDataValueKeys().iterator(); while (appDataValueKeysIterator.hasNext()) { final String appDataValueKey = appDataValueKeysIterator.next(); if (appDataValueKey == "*") { for (Entry<String, String> entry : currentAppDataValues.entrySet()) { mapper.deleteAppDataValueByKey(currentAppData.getId(), entry.getKey()); } break; } if (currentAppDataValues.containsKey(appDataValueKey)) { mapper.deleteAppDataValueByKey(currentAppData.getId(), appDataValueKey); } } mapper.flush(); log.info("Deleting the AppDataDTO cache for gadDef " + applicationId + ", open social id: " + openSocialId); cache.delete(CacheKeys.APPDATA_BY_GADGET_DEFINITION_ID_AND_UNDERSCORE_AND_PERSON_OPEN_SOCIAL_ID + applicationId + "_" + openSocialId); } } catch (Exception ex) { log.error("Error occurred deleting app data.", ex); throw new ExecutionException("Error occurred deleting app data.", ex); } return null; } DeleteAppDataExecution(final AppDataMapper inMapper, final Cache inCache); @Override Integer execute(final PrincipalActionContext inActionContext); }
DeleteAppDataExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Integer execute(final PrincipalActionContext inActionContext) throws ExecutionException { DeleteAppDataRequest inRequest = (DeleteAppDataRequest) inActionContext.getParams(); long applicationId = inRequest.getApplicationId(); String openSocialId = inRequest.getOpenSocialId(); Map<String, String> currentAppDataValues; try { AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, openSocialId); if (currentAppData != null) { currentAppDataValues = new HashMap<String, String>(currentAppData.getValues()); Iterator<String> appDataValueKeysIterator = inRequest.getAppDataValueKeys().iterator(); while (appDataValueKeysIterator.hasNext()) { final String appDataValueKey = appDataValueKeysIterator.next(); if (appDataValueKey == "*") { for (Entry<String, String> entry : currentAppDataValues.entrySet()) { mapper.deleteAppDataValueByKey(currentAppData.getId(), entry.getKey()); } break; } if (currentAppDataValues.containsKey(appDataValueKey)) { mapper.deleteAppDataValueByKey(currentAppData.getId(), appDataValueKey); } } mapper.flush(); log.info("Deleting the AppDataDTO cache for gadDef " + applicationId + ", open social id: " + openSocialId); cache.delete(CacheKeys.APPDATA_BY_GADGET_DEFINITION_ID_AND_UNDERSCORE_AND_PERSON_OPEN_SOCIAL_ID + applicationId + "_" + openSocialId); } } catch (Exception ex) { log.error("Error occurred deleting app data.", ex); throw new ExecutionException("Error occurred deleting app data.", ex); } return null; } DeleteAppDataExecution(final AppDataMapper inMapper, final Cache inCache); @Override Integer execute(final PrincipalActionContext inActionContext);  }