@SuppressWarnings("unchecked") @Test public final void testExecuteEmpty() throws Exception { final List<GadgetMetaDataDTO> metaData = new ArrayList<GadgetMetaDataDTO>(); context.checking(new Expectations() { { oneOf(fetcher).getGadgetsMetaData(with(any(Map.class))); will(returnValue(metaData)); } }); sut.populate(pluginDefinitionMock, "src/test/resources/plugins/goodplugin.xml"); assertTrue(pluginDefinitionMock.getObjectType() == BaseObjectType.NOTE); assertTrue(pluginDefinitionMock.getUpdateFrequency() == 9L); context.assertIsSatisfied(); }
@Override public void populate(final PluginDefinition inPluginDefinition, final String inPluginDefinitionUrl) { boolean hasFeature = false; ValidationException ve = new ValidationException(); String errorMessage = ""; try { hasFeature = checkForRequiredFeature(inPluginDefinitionUrl); } catch (Exception ex) { log.debug(CANT_FIND_PLUGIN, ex); ve.addError("url", CANT_FIND_PLUGIN); throw ve; } final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inPluginDefinitionUrl, inPluginDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); for (UserPrefDTO up : metadata.getUserPrefs()) { if ("updateFrequency".equals(up.getName())) { try { Long updateFreq = Long.parseLong(up.getDefaultValue()); inPluginDefinition.setUpdateFrequency(updateFreq); } catch (Exception ex) { errorMessage += UPDATE_FREQUENCY_ERROR; } } else if ("objectType".equals(up.getName())) { try { inPluginDefinition.setObjectType(BaseObjectType.valueOf(up.getDefaultValue())); } catch (Exception ex) { errorMessage += OBJECTTYPE_ERROR; } } } } if (!hasFeature) { errorMessage += FEATURE_ERROR; } if (!errorMessage.equals("")) { ve.addError("url", errorMessage); } else { if (inPluginDefinition.getObjectType() == null) { inPluginDefinition.setObjectType(defaultObjectType); } if (inPluginDefinition.getUpdateFrequency() == null) { inPluginDefinition.setUpdateFrequency(defaultUpdateFrequency); } } if (!ve.getErrors().isEmpty()) { throw ve; } } catch (ValidationException ve2) { throw ve2; } catch (Exception ex) { ve.addError("url", "Error retreiving plugin data."); log.debug(ex.fillInStackTrace()); throw ve; } }
PluginDefinitionPopulator implements GalleryItemPopulator<PluginDefinition> { @Override public void populate(final PluginDefinition inPluginDefinition, final String inPluginDefinitionUrl) { boolean hasFeature = false; ValidationException ve = new ValidationException(); String errorMessage = ""; try { hasFeature = checkForRequiredFeature(inPluginDefinitionUrl); } catch (Exception ex) { log.debug(CANT_FIND_PLUGIN, ex); ve.addError("url", CANT_FIND_PLUGIN); throw ve; } final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inPluginDefinitionUrl, inPluginDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); for (UserPrefDTO up : metadata.getUserPrefs()) { if ("updateFrequency".equals(up.getName())) { try { Long updateFreq = Long.parseLong(up.getDefaultValue()); inPluginDefinition.setUpdateFrequency(updateFreq); } catch (Exception ex) { errorMessage += UPDATE_FREQUENCY_ERROR; } } else if ("objectType".equals(up.getName())) { try { inPluginDefinition.setObjectType(BaseObjectType.valueOf(up.getDefaultValue())); } catch (Exception ex) { errorMessage += OBJECTTYPE_ERROR; } } } } if (!hasFeature) { errorMessage += FEATURE_ERROR; } if (!errorMessage.equals("")) { ve.addError("url", errorMessage); } else { if (inPluginDefinition.getObjectType() == null) { inPluginDefinition.setObjectType(defaultObjectType); } if (inPluginDefinition.getUpdateFrequency() == null) { inPluginDefinition.setUpdateFrequency(defaultUpdateFrequency); } } if (!ve.getErrors().isEmpty()) { throw ve; } } catch (ValidationException ve2) { throw ve2; } catch (Exception ex) { ve.addError("url", "Error retreiving plugin data."); log.debug(ex.fillInStackTrace()); throw ve; } } }
PluginDefinitionPopulator implements GalleryItemPopulator<PluginDefinition> { @Override public void populate(final PluginDefinition inPluginDefinition, final String inPluginDefinitionUrl) { boolean hasFeature = false; ValidationException ve = new ValidationException(); String errorMessage = ""; try { hasFeature = checkForRequiredFeature(inPluginDefinitionUrl); } catch (Exception ex) { log.debug(CANT_FIND_PLUGIN, ex); ve.addError("url", CANT_FIND_PLUGIN); throw ve; } final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inPluginDefinitionUrl, inPluginDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); for (UserPrefDTO up : metadata.getUserPrefs()) { if ("updateFrequency".equals(up.getName())) { try { Long updateFreq = Long.parseLong(up.getDefaultValue()); inPluginDefinition.setUpdateFrequency(updateFreq); } catch (Exception ex) { errorMessage += UPDATE_FREQUENCY_ERROR; } } else if ("objectType".equals(up.getName())) { try { inPluginDefinition.setObjectType(BaseObjectType.valueOf(up.getDefaultValue())); } catch (Exception ex) { errorMessage += OBJECTTYPE_ERROR; } } } } if (!hasFeature) { errorMessage += FEATURE_ERROR; } if (!errorMessage.equals("")) { ve.addError("url", errorMessage); } else { if (inPluginDefinition.getObjectType() == null) { inPluginDefinition.setObjectType(defaultObjectType); } if (inPluginDefinition.getUpdateFrequency() == null) { inPluginDefinition.setUpdateFrequency(defaultUpdateFrequency); } } if (!ve.getErrors().isEmpty()) { throw ve; } } catch (ValidationException ve2) { throw ve2; } catch (Exception ex) { ve.addError("url", "Error retreiving plugin data."); log.debug(ex.fillInStackTrace()); throw ve; } } PluginDefinitionPopulator(final GadgetMetaDataFetcher inMetaDataFetcher,
            final Long inDefaultUpdateFrequency, final BaseObjectType inDefaultObjectType); }
PluginDefinitionPopulator implements GalleryItemPopulator<PluginDefinition> { @Override public void populate(final PluginDefinition inPluginDefinition, final String inPluginDefinitionUrl) { boolean hasFeature = false; ValidationException ve = new ValidationException(); String errorMessage = ""; try { hasFeature = checkForRequiredFeature(inPluginDefinitionUrl); } catch (Exception ex) { log.debug(CANT_FIND_PLUGIN, ex); ve.addError("url", CANT_FIND_PLUGIN); throw ve; } final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inPluginDefinitionUrl, inPluginDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); for (UserPrefDTO up : metadata.getUserPrefs()) { if ("updateFrequency".equals(up.getName())) { try { Long updateFreq = Long.parseLong(up.getDefaultValue()); inPluginDefinition.setUpdateFrequency(updateFreq); } catch (Exception ex) { errorMessage += UPDATE_FREQUENCY_ERROR; } } else if ("objectType".equals(up.getName())) { try { inPluginDefinition.setObjectType(BaseObjectType.valueOf(up.getDefaultValue())); } catch (Exception ex) { errorMessage += OBJECTTYPE_ERROR; } } } } if (!hasFeature) { errorMessage += FEATURE_ERROR; } if (!errorMessage.equals("")) { ve.addError("url", errorMessage); } else { if (inPluginDefinition.getObjectType() == null) { inPluginDefinition.setObjectType(defaultObjectType); } if (inPluginDefinition.getUpdateFrequency() == null) { inPluginDefinition.setUpdateFrequency(defaultUpdateFrequency); } } if (!ve.getErrors().isEmpty()) { throw ve; } } catch (ValidationException ve2) { throw ve2; } catch (Exception ex) { ve.addError("url", "Error retreiving plugin data."); log.debug(ex.fillInStackTrace()); throw ve; } } PluginDefinitionPopulator(final GadgetMetaDataFetcher inMetaDataFetcher,
            final Long inDefaultUpdateFrequency, final BaseObjectType inDefaultObjectType); @Override void populate(final PluginDefinition inPluginDefinition,
            final String inPluginDefinitionUrl); }
PluginDefinitionPopulator implements GalleryItemPopulator<PluginDefinition> { @Override public void populate(final PluginDefinition inPluginDefinition, final String inPluginDefinitionUrl) { boolean hasFeature = false; ValidationException ve = new ValidationException(); String errorMessage = ""; try { hasFeature = checkForRequiredFeature(inPluginDefinitionUrl); } catch (Exception ex) { log.debug(CANT_FIND_PLUGIN, ex); ve.addError("url", CANT_FIND_PLUGIN); throw ve; } final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inPluginDefinitionUrl, inPluginDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); for (UserPrefDTO up : metadata.getUserPrefs()) { if ("updateFrequency".equals(up.getName())) { try { Long updateFreq = Long.parseLong(up.getDefaultValue()); inPluginDefinition.setUpdateFrequency(updateFreq); } catch (Exception ex) { errorMessage += UPDATE_FREQUENCY_ERROR; } } else if ("objectType".equals(up.getName())) { try { inPluginDefinition.setObjectType(BaseObjectType.valueOf(up.getDefaultValue())); } catch (Exception ex) { errorMessage += OBJECTTYPE_ERROR; } } } } if (!hasFeature) { errorMessage += FEATURE_ERROR; } if (!errorMessage.equals("")) { ve.addError("url", errorMessage); } else { if (inPluginDefinition.getObjectType() == null) { inPluginDefinition.setObjectType(defaultObjectType); } if (inPluginDefinition.getUpdateFrequency() == null) { inPluginDefinition.setUpdateFrequency(defaultUpdateFrequency); } } if (!ve.getErrors().isEmpty()) { throw ve; } } catch (ValidationException ve2) { throw ve2; } catch (Exception ex) { ve.addError("url", "Error retreiving plugin data."); log.debug(ex.fillInStackTrace()); throw ve; } } PluginDefinitionPopulator(final GadgetMetaDataFetcher inMetaDataFetcher,
            final Long inDefaultUpdateFrequency, final BaseObjectType inDefaultObjectType); @Override void populate(final PluginDefinition inPluginDefinition,
            final String inPluginDefinitionUrl);  }