final GalleryItemCategory galleryItemCategory = new GalleryItemCategory("CITY");
final String urlPath = "src/main/webapp/plugin/plugin.xml";
final PluginDefinition pluginDef = new PluginDefinition();
pluginDef.setUpdateFrequency(9L);
pluginDef.setUrl(urlPath);
pluginDef.setCategory(galleryItemCategory);
final String username = "validuser";
final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
formData.put("url", urlPath);
formData.put("category", "CITY");
context.checking(new Expectations()
{
{
oneOf(userDetails).getParams();
will(returnValue(formData));
oneOf(pluginItemGetter).provide(userDetails, formData);
will(returnValue(pluginDef));
oneOf(galleryItemCategoryMapper).findByName(GalleryItemType.PLUGIN, "CITY");
will(returnValue(galleryItemCategory));
oneOf(pluginItemPopulator).populate(pluginDef, urlPath);
oneOf(pluginItemSaver).save(pluginDef);
}
});
Serializable[] params = { formData };
// Make the call
PluginDefinition actual = (PluginDefinition) sutPlugin.execute(userDetails);
context.assertIsSatisfied();
assertEquals("property should be gotten", new Long(9), pluginDef.getUpdateFrequency());
assertEquals("property should be gotten", urlPath, pluginDef.getUrl());