Configuration pluginConfig = new Configuration();
Configuration jobsConfig = new Configuration();
pluginConfig.put(new PropertySimple("first", "last"));
jobsConfig.put(new PropertySimple("aaa", "bbb"));
Plugin plugin = new Plugin(name, path);
plugin.setDisplayName(displayName);
plugin.setEnabled(enabled);
plugin.setMD5(md5);
plugin.setVersion(version);
plugin.setAmpsVersion(ampsVersion);
plugin.setDescription(description);
plugin.setHelp(help);
plugin.setContent(content);
plugin.setDeployment(deployment);
em.persist(plugin);
assert plugin.getId() > 0;
plugin = em.find(Plugin.class, plugin.getId());
assert plugin != null;
assert plugin.getId() > 0;
assert plugin.getName().equals(name);
assert plugin.getPath().equals(path);
assert plugin.getDisplayName().equals(displayName);
assert plugin.isEnabled() == enabled;
assert plugin.getMD5().equals(md5);
assert plugin.getVersion().equals(version);
assert plugin.getAmpsVersion().equals(ampsVersion);
assert plugin.getDescription().equals(description);
assert plugin.getDeployment() == deployment;
assert plugin.getHelp().equals(help);
assert new String(plugin.getContent()).equals(new String(content));
// test our queries that purposefully do not load in the content blob
query = em.createNamedQuery(Plugin.QUERY_FIND_BY_NAME);
query.setParameter("name", name);
plugin = (Plugin) query.getSingleResult();
assert plugin != null;
assert plugin.getId() > 0;
assert plugin.getName().equals(name);
assert plugin.getPath().equals(path);
assert plugin.getDisplayName().equals(displayName);
assert plugin.isEnabled() == enabled;
assert plugin.getMD5().equals(md5);
assert plugin.getVersion().equals(version);
assert plugin.getAmpsVersion().equals(ampsVersion);
assert plugin.getDescription().equals(description);
assert plugin.getDeployment() == deployment;
assert plugin.getHelp().equals(help);
assert plugin.getContent() == null;
query = em.createNamedQuery(Plugin.QUERY_FIND_BY_IDS);
query.setParameter("ids", Arrays.asList(Integer.valueOf(plugin.getId())));
plugin = (Plugin) query.getSingleResult();
assert plugin != null;
assert plugin.getId() > 0;
assert plugin.getName().equals(name);
assert plugin.getPath().equals(path);
assert plugin.getDisplayName().equals(displayName);
assert plugin.isEnabled() == enabled;
assert plugin.getMD5().equals(md5);
assert plugin.getVersion().equals(version);
assert plugin.getAmpsVersion().equals(ampsVersion);
assert plugin.getDescription().equals(description);
assert plugin.getDeployment() == deployment;
assert plugin.getHelp().equals(help);
assert plugin.getContent() == null;
query = em.createNamedQuery(Plugin.QUERY_FIND_ALL_INSTALLED);
@SuppressWarnings("unchecked")
List<Plugin> all = query.getResultList();
boolean got_it = false;
for (Plugin p : all) {
if (p.getName().equals(name)) {
got_it = true;
assert p.getId() > 0;
assert p.getName().equals(name);
assert p.getPath().equals(path);
assert p.getDisplayName().equals(displayName);
assert p.isEnabled() == enabled;
assert p.getMD5().equals(md5);
assert p.getVersion().equals(version);
assert plugin.getAmpsVersion().equals(ampsVersion);
assert p.getDescription().equals(description);
assert plugin.getDeployment() == deployment;
assert p.getHelp().equals(help);
assert p.getContent() == null;
break;
}
}
assert got_it : "findAll query failed to get our plugin";
// mark a plugin deleted - all of our queries should then never see it
plugin.setStatus(PluginStatusType.DELETED);
plugin = em.merge(plugin);
query = em.createNamedQuery(Plugin.QUERY_FIND_BY_NAME);
query.setParameter("name", name);
List<?> results = query.getResultList();
assert results.size() == 0;
query = em.createNamedQuery(Plugin.QUERY_FIND_BY_IDS);
query.setParameter("ids", Arrays.asList(Integer.valueOf(plugin.getId())));
results = query.getResultList();
assert results.size() == 0;
query = em.createNamedQuery(Plugin.QUERY_FIND_ALL_INSTALLED);
results = query.getResultList();