p1.setErrorMessage(ThrowableUtil.getStackAsString(new Exception(
"This should be a boolean value - true or false")));
c.put(p1);
em.persist(c);
AbstractResourceConfigurationUpdate cur = new ResourceConfigurationUpdate(resource, c, "dummy");
em.persist(cur);
AbstractResourceConfigurationUpdate copy = em.find(AbstractResourceConfigurationUpdate.class,
cur.getId());
assert copy.getStatus().equals(ConfigurationUpdateStatus.INPROGRESS) : copy;
assert copy.getSubjectName().equals("dummy") : copy;
assert copy.getCreatedTime() > 0 : copy;
assert copy.getModifiedTime() > 0 : copy;
assert copy.getErrorMessage() == null : copy;
assert copy.getConfiguration().getSimple("first") != null : copy;
assert copy.getConfiguration().getSimple("first").getErrorMessage()
.indexOf("This should be a boolean value - true or false") > -1 : copy;
assert copy.getConfiguration().getSimple("first").getStringValue().equals("firstValue") : copy;
// let's pretend we failed the update
cur.setErrorMessage(ThrowableUtil.getStackAsString((new Exception("update error here"))));
assert copy.getStatus().equals(ConfigurationUpdateStatus.FAILURE) : copy; // setting the error message also sets status to failure
copy = em.find(AbstractResourceConfigurationUpdate.class, cur.getId());
assert copy.getStatus().equals(ConfigurationUpdateStatus.FAILURE) : copy;
assert copy.getErrorMessage().indexOf("update error here") > -1 : copy;
assert copy.getConfiguration().getSimple("first") != null : copy;
assert copy.getConfiguration().getSimple("first").getErrorMessage()
.indexOf("This should be a boolean value - true or false") > -1 : copy;
assert copy.getConfiguration().getSimple("first").getStringValue().equals("firstValue") : copy;
}
});
}