assertEquals(0, commandLineCommand.compareTo(commandLineCommand));
CommandLineCommand otherCommand = new CommandLineCommand();
otherCommand.setSystemCommand(true);
- assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
+ assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
otherCommand.getArgumentList().add(new CommandLineArgument("testArgument"));
- assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
+ assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
}
@Test
public void testCompareKeywordList() {
CommandLineCommand otherCommand = new CommandLineCommand();
otherCommand.getKeywordlist().add("test");
- assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
+ assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
commandLineCommand.getKeywordlist().add("test");
assertEquals(0, commandLineCommand.compareTo(otherCommand));
commandLineCommand.getKeywordlist().add("test2");
- assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
+ assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
otherCommand.getKeywordlist().add("test3");
- assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
+ assertThat(commandLineCommand).isNotEqualByComparingTo(otherCommand);
}
@Test
schemaHelper = new SchemaHelperFactory().createSchemaHelper(albumDefinition.getKey(),
albumDefinition.getItemSchema());
} catch (final ContextRuntimeException e) {
- final String resultString = "could not initiate schema management for context album " + albumDefinition;
+ final var resultString = "could not initiate schema management for context album " + albumDefinition;
LOGGER.warn(resultString, e);
throw new ContextException(resultString, e);
}
@Override
public Object get(final Object key) {
if (key == null) {
- final String returnString =
+ final var returnString =
ALBUM + albumDefinition.getId() + "\" null keys are illegal on keys for get()";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
@Override
public Object put(final String key, final Object incomingValue) {
if (key == null) {
- final String returnString =
+ final var returnString =
ALBUM + albumDefinition.getId() + "\" null keys are illegal on keys for put()";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
if (incomingValue == null) {
- final String returnString = ALBUM + albumDefinition.getId() + "\" null values are illegal on key \""
+ final var returnString = ALBUM + albumDefinition.getId() + "\" null values are illegal on key \""
+ key + "\" for put()";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
if (!albumDefinition.isWritable()) {
- final String returnString = ALBUM + albumDefinition.getId()
+ final var returnString = ALBUM + albumDefinition.getId()
+ "\" put() not allowed on read only albums for key=\"" + key + "\", value=\"" + incomingValue;
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
// Put the translated value on the map and return the old map value
return albumMap.put(key, valueToPut);
} catch (final ContextRuntimeException e) {
- final String returnString = "Failed to set context value for key \"" + key + "\" in album \""
+ final var returnString = "Failed to set context value for key \"" + key + "\" in album \""
+ albumDefinition.getId() + "\": " + e.getMessage();
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString, e);
@Override
public void putAll(final Map<? extends String, ? extends Object> incomingContextAlbum) {
if (!albumDefinition.isWritable()) {
- final String returnString =
+ final var returnString =
ALBUM + albumDefinition.getId() + "\" putAll() not allowed on read only albums";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
@Override
public Object remove(final Object key) {
if (!albumDefinition.isWritable()) {
- final String returnString = ALBUM + albumDefinition.getId()
+ final var returnString = ALBUM + albumDefinition.getId()
+ "\" remove() not allowed on read only albums for key=\"" + key + "\"";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
@Override
public void clear() {
if (!albumDefinition.isWritable()) {
- final String returnString =
+ final var returnString =
ALBUM + albumDefinition.getId() + "\" clear() not allowed on read only albums";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
// Get the context album definition
final AxContextAlbum album = ModelService.getModel(AxContextAlbums.class).get(axContextAlbumKey);
if (album == null) {
- final String resultString = "context album " + axContextAlbumKey.getId() + " does not exist";
+ final var resultString = "context album " + axContextAlbumKey.getId() + " does not exist";
LOGGER.warn(resultString);
throw new ContextException(resultString);
}
// Check if the context album is valid
final AxValidationResult result = album.validate(new AxValidationResult());
if (!result.isValid()) {
- final String resultString = "context album definition for " + album.getKey().getId() + " is invalid"
+ final var resultString = "context album definition for " + album.getKey().getId() + " is invalid"
+ result;
LOGGER.warn(resultString);
throw new ContextException(resultString);
// Get the schema of the context album
final AxContextSchema schema = ModelService.getModel(AxContextSchemas.class).get(album.getItemSchema());
if (schema == null) {
- final String resultString = "schema \"" + album.getItemSchema().getId() + "\" for context album "
+ final var resultString = "schema \"" + album.getItemSchema().getId() + "\" for context album "
+ album.getKey().getId() + " does not exist";
LOGGER.warn(resultString);
throw new ContextException(resultString);
// Check the class is a distributor
if (!(contextDistributorObject instanceof Distributor)) {
- final String returnString = "Specified Apex context distributor plugin class \"" + pluginClass
+ final var returnString = "Specified Apex context distributor plugin class \"" + pluginClass
+ "\" does not implement the ContextDistributor interface";
throw new ContextException(returnString);
}
@Override
public Object createNewInstance() {
if (schemaClass == null) {
- final String returnString =
+ final var returnString =
userKey.getId() + ": could not create an instance, schema class for the schema is null";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
try {
return schemaClass.getDeclaredConstructor().newInstance();
} catch (final Exception e) {
- final String returnString =
+ final var returnString =
userKey.getId() + ": could not create an instance of class \"" + schemaClass.getName()
+ "\" using the default constructor \"" + schemaClass.getSimpleName() + "()\"";
LOGGER.warn(returnString, e);
@Override
public Object createNewInstance(final String stringValue) {
if (schemaClass == null) {
- final String returnString =
+ final var returnString =
userKey.getId() + ": could not create an instance, schema class for the schema is null";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
// Invoke the constructor
return stringConstructor.newInstance(stringValue);
} catch (final Exception e) {
- final String returnString =
+ final var returnString =
userKey.getId() + ": could not create an instance of class \"" + schemaClass.getName()
+ "\" using the string constructor \"" + schemaClass.getSimpleName() + "(String)\"";
LOGGER.warn(returnString, e);
// Get the schema for items in the album
final AxContextSchema schema = ModelService.getModel(AxContextSchemas.class).get(schemaKey);
if (schema == null) {
- final String resultString =
+ final var resultString =
"schema \"" + schemaKey.getId() + "\" for entity " + owningEntityKey.getId() + " does not exist";
LOGGER.warn(resultString);
throw new ContextRuntimeException(resultString);
final SchemaHelperParameters schemaHelperParameters =
schemaParameters.getSchemaHelperParameters(schema.getSchemaFlavour());
if (schemaHelperParameters == null) {
- final String resultString = "context schema helper parameters not found for context schema \""
+ final var resultString = "context schema helper parameters not found for context schema \""
+ schema.getSchemaFlavour() + "\"";
LOGGER.warn(resultString);
throw new ContextRuntimeException(resultString);
try {
schemaHelperObject = Class.forName(pluginClass).getDeclaredConstructor().newInstance();
} catch (final Exception e) {
- final String resultString = "Apex context schema helper class not found for context schema helper plugin \""
+ final var resultString = "Apex context schema helper class not found for context schema helper plugin \""
+ pluginClass + "\"";
LOGGER.warn(resultString, e);
throw new ContextRuntimeException(resultString, e);
// Check the class is a schema helper
if (!(schemaHelperObject instanceof SchemaHelper)) {
- final String resultString = "Specified Apex context schema helper plugin class \"" + pluginClass
+ final var resultString = "Specified Apex context schema helper plugin class \"" + pluginClass
+ "\" does not implement the SchemaHelper interface";
LOGGER.warn(resultString);
throw new ContextRuntimeException(resultString);
}
if (getSchemaClass() == null) {
- final String returnString =
+ final var returnString =
getUserKey().getId() + ": could not create an instance, schema class for the schema is null";
LOGGER.warn(returnString);
throw new ContextRuntimeException(returnString);
}
if (incomingObject instanceof JsonElement) {
- final String elementJsonString = getGson().toJson((JsonElement) incomingObject);
+ final var elementJsonString = getGson().toJson((JsonElement) incomingObject);
return getGson().fromJson(elementJsonString, this.getSchemaClass());
}
return incomingObject;
}
- final String returnString = getUserKey().getId() + ": the object \"" + incomingObject + "\" of type \""
+ final var returnString = getUserKey().getId() + ": the object \"" + incomingObject + "\" of type \""
+ incomingObject.getClass().getName()
+ "\" is not an instance of JsonObject and is not assignable to \"" + getSchemaClass().getName() + "\"";
LOGGER.warn(returnString);
// Use Gson to translate the object
return getGson().toJson(schemaObject);
} else {
- final String returnString = getUserKey().getId() + ": object \"" + schemaObject.toString()
+ final var returnString = getUserKey().getId() + ": object \"" + schemaObject.toString()
+ "\" of class \"" + schemaObject.getClass().getName() + "\" not compatible with class \""
+ getSchemaClass().getName() + "\"";
LOGGER.warn(returnString);
final Constructor<?> stringConstructor = getSchemaClass().getConstructor(String.class);
return stringConstructor.newInstance(object.toString());
} catch (final Exception e) {
- final String returnString = getUserKey().getId() + ": object \"" + object.toString() + "\" of class \""
+ final var returnString = getUserKey().getId() + ": object \"" + object.toString() + "\" of class \""
+ object.getClass().getName() + "\" not compatible with class \"" + getSchemaClass().getName()
+ "\"";
LOGGER.warn(returnString, e);
try {
adapterObject = jsonAdapterEntry.getAdaptorClazz().getDeclaredConstructor().newInstance();
} catch (Exception e) {
- final String returnString = getUserKey().getId() + ": instantiation of adapter class \""
+ final var returnString = getUserKey().getId() + ": instantiation of adapter class \""
+ jsonAdapterEntry.getAdaptorClass() + "\" to decode and encode class \""
+ jsonAdapterEntry.getAdaptedClass() + "\" failed: " + e.getMessage();
LOGGER.warn(returnString, e);
*/
public void monitorInit(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final Object value) {
- String monitorInitString = monitor("INIT", null, albumKey, schemaKey, name, value);
+ var monitorInitString = monitor("INIT", null, albumKey, schemaKey, name, value);
LOGGER.trace(monitorInitString);
}
*/
public void monitorInit(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final Object value, final AxConcept[] userArtifactStack) {
- String monitorInitString = monitor("INIT", userArtifactStack, albumKey, schemaKey, name, value);
+ var monitorInitString = monitor("INIT", userArtifactStack, albumKey, schemaKey, name, value);
LOGGER.trace(monitorInitString);
}
*/
public void monitorDelete(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final Object value, final AxConcept[] userArtifactStack) {
- String monitorDeleteString = monitor("DEL", userArtifactStack, albumKey, schemaKey, name, value);
+ var monitorDeleteString = monitor("DEL", userArtifactStack, albumKey, schemaKey, name, value);
LOGGER.trace(monitorDeleteString);
}
*/
public void monitorGet(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final Object value, final AxConcept[] userArtifactStack) {
- String monitorGetString = monitor("GET", userArtifactStack, albumKey, schemaKey, name, value);
+ var monitorGetString = monitor("GET", userArtifactStack, albumKey, schemaKey, name, value);
LOGGER.trace(monitorGetString);
}
*/
public void monitorSet(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final Object value, final AxConcept[] userArtifactStack) {
- String monitorSetString = monitor("SET", userArtifactStack, albumKey, schemaKey, name, value);
+ var monitorSetString = monitor("SET", userArtifactStack, albumKey, schemaKey, name, value);
LOGGER.trace(monitorSetString);
}
*/
public void monitorReadLock(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final AxConcept[] userArtifactStack) {
- String monitorReadLockString = monitor("READLOCK", userArtifactStack, albumKey, schemaKey, name, null);
+ var monitorReadLockString = monitor("READLOCK", userArtifactStack, albumKey, schemaKey, name, null);
LOGGER.trace(monitorReadLockString);
}
*/
public void monitorWriteLock(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final AxConcept[] userArtifactStack) {
- String writeLockMonitorString = monitor("WRITELOCK", userArtifactStack, albumKey, schemaKey, name, null);
+ var writeLockMonitorString = monitor("WRITELOCK", userArtifactStack, albumKey, schemaKey, name, null);
LOGGER.trace(writeLockMonitorString);
}
*/
public void monitorReadUnlock(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final AxConcept[] userArtifactStack) {
- String monitorReadUnlockString = monitor("READUNLOCK", userArtifactStack, albumKey, schemaKey, name, null);
+ var monitorReadUnlockString = monitor("READUNLOCK", userArtifactStack, albumKey, schemaKey, name, null);
LOGGER.trace(monitorReadUnlockString);
}
*/
public void monitorWriteUnlock(final AxArtifactKey albumKey, final AxArtifactKey schemaKey, final String name,
final AxConcept[] userArtifactStack) {
- String monitorWriteUnlockString = monitor("WRITEUNLOCK", userArtifactStack, albumKey, schemaKey, name, null);
+ var monitorWriteUnlockString = monitor("WRITEUNLOCK", userArtifactStack, albumKey, schemaKey, name, null);
LOGGER.trace(monitorWriteUnlockString);
}
*/
private String monitor(final String preamble, final AxConcept[] userArtifactStack, final AxArtifactKey albumKey,
final AxArtifactKey schemaKey, final String name, final Object value) {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(preamble);
builder.append(",[");
if (userArtifactStack != null) {
- boolean first = true;
+ var first = true;
for (final AxConcept stackKey : userArtifactStack) {
if (first) {
first = false;