mirror of
https://github.com/optim-enterprises-bv/siembol.git
synced 2025-11-01 19:07:59 +00:00
adding javadoc for config editor core
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
/**
|
||||
* An object for providing authorisation for Siembol services
|
||||
*
|
||||
* <p>This interface is for providing authorisation for a Siembol services.
|
||||
* It decides whether the user is allowed to access a service under its role.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface AuthorisationProvider {
|
||||
enum AuthorisationResult {
|
||||
UNDEFINED,
|
||||
@@ -7,5 +15,11 @@ public interface AuthorisationProvider {
|
||||
FORBIDDEN,
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets authorisation decision for a user and a service
|
||||
* @param user a user info object
|
||||
* @param serviceName the name of teh service
|
||||
* @return the authorisation result
|
||||
*/
|
||||
AuthorisationResult getUserAuthorisation(UserInfo user, String serviceName);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,13 @@ import uk.co.gresearch.siembol.configeditor.model.ConfigEditorUiLayout;
|
||||
import java.io.*;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A class with static helper methods for config editor
|
||||
*
|
||||
* <p>This class exposes static helper methods for config editor.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ConfigEditorUtils {
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult;
|
||||
|
||||
/**
|
||||
* An object for importing configurations
|
||||
*
|
||||
* <p>This interface is for providing functionality for importing open standard configuration into Siembol.
|
||||
* Moreover, it validates attributes and provides importer attributes schema.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface ConfigImporter {
|
||||
/**
|
||||
* Gets a json schema for importer attributes
|
||||
* @return config editor result with json schema
|
||||
*/
|
||||
ConfigEditorResult getImporterAttributesSchema();
|
||||
|
||||
/**
|
||||
* Validates importer attributes
|
||||
* @param attributes a json string with importer attributes
|
||||
* @return config editor result with OK status code if the attributes are valid, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
ConfigEditorResult validateImporterAttributes(String attributes);
|
||||
|
||||
/**
|
||||
* Imports open standard configuration into Siembol syntax
|
||||
* @param user a user info object
|
||||
* @param importerAttributes a json string with importer attributes
|
||||
* @param configuration a configuration for importing into Siembol
|
||||
* @return config editor result with OK status code and the imported config if the import was successful, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
ConfigEditorResult importConfig(UserInfo user, String importerAttributes, String configuration);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,14 @@ package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* An object that represents information about a configuration change
|
||||
*
|
||||
* <p>This class represents information about configuration change such as the name of the configuration,
|
||||
* its version, content etc.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ConfigInfo {
|
||||
private String name;
|
||||
private Map<String, Optional<String>> filesContent;
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
/**
|
||||
* An enum of configuration types
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see #RULE
|
||||
* @see #CONFIG
|
||||
* @see #TEST_CASE
|
||||
* @see #ADMIN_CONFIG
|
||||
*/
|
||||
public enum ConfigInfoType {
|
||||
RULE("rule", "rules", "Rules"),
|
||||
CONFIG("configuration", "configurations", "Configurations"),
|
||||
|
||||
@@ -4,35 +4,82 @@ import org.springframework.boot.actuate.health.Health;
|
||||
import uk.co.gresearch.siembol.configeditor.model.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.OK;
|
||||
|
||||
/**
|
||||
* An object for configuration schema service
|
||||
*
|
||||
* <p>This interface is for providing functionality for configuration schema service.
|
||||
* It validates configurations, and provides a json schema.
|
||||
* it provides config importers and testers registered for the service.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ConfigTester
|
||||
* @see ConfigImporter
|
||||
*
|
||||
*/
|
||||
public interface ConfigSchemaService extends HealthCheckable {
|
||||
String NOT_IMPLEMENTED_MSG = "Not implemented";
|
||||
String SCHEMA_INIT_ERROR = "Error during computing json schema";
|
||||
|
||||
/**
|
||||
* Gets a json schema for configurations
|
||||
* @return a config editor result with a json schema for configurations
|
||||
*/
|
||||
ConfigEditorResult getSchema();
|
||||
|
||||
/**
|
||||
* Validates a configuration
|
||||
* @param configuration a json string with configuration
|
||||
* @return a config editor result with OK status code if the configuration is valid, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
ConfigEditorResult validateConfiguration(String configuration);
|
||||
|
||||
/**
|
||||
* Validates configurations
|
||||
* @param configurations a json string with configurations
|
||||
* @return a config editor result with OK status code if the configurations are valid, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
ConfigEditorResult validateConfigurations(String configurations);
|
||||
|
||||
/**
|
||||
* Gets config importers
|
||||
* @return the map of an importer name string to a config importer object
|
||||
*/
|
||||
Map<String, ConfigImporter> getConfigImporters();
|
||||
|
||||
/**
|
||||
* Gets config testers
|
||||
* @return a config editor result with config testers registered for the service
|
||||
*/
|
||||
default ConfigEditorResult getConfigTesters() {
|
||||
ConfigEditorAttributes attributes = new ConfigEditorAttributes();
|
||||
attributes.setConfigTesters(new ArrayList<>());
|
||||
return new ConfigEditorResult(OK, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a config tester by name
|
||||
* @return a config tester
|
||||
*/
|
||||
ConfigTester getConfigTester(String name);
|
||||
|
||||
/**
|
||||
* Checks a health of teh service
|
||||
* @return a health object with the status
|
||||
* @see Health
|
||||
*/
|
||||
default Health checkHealth() { return Health.up().build(); }
|
||||
|
||||
/**
|
||||
* Get config importers
|
||||
* @return config editor result with config importers
|
||||
*/
|
||||
default ConfigEditorResult getImporters() {
|
||||
List<ConfigImporterDto> importers = getConfigImporters().entrySet().stream().map(x -> {
|
||||
ConfigImporterDto importer = new ConfigImporterDto();
|
||||
@@ -46,7 +93,19 @@ public interface ConfigSchemaService extends HealthCheckable {
|
||||
return new ConfigEditorResult(OK, attributes);
|
||||
}
|
||||
|
||||
default ConfigEditorResult importConfig(UserInfo user, String importerName, String importerAttributes, String configToImport) {
|
||||
/**
|
||||
* Imports a config into a service syntax
|
||||
* @param user a user info object
|
||||
* @param importerName the name of teh importer
|
||||
* @param importerAttributes a json string with importer attributes
|
||||
* @param configToImport a string with configuration to be imported
|
||||
* @return config editor result with OK status code and the imported config if the import was successful, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
default ConfigEditorResult importConfig(UserInfo user,
|
||||
String importerName,
|
||||
String importerAttributes,
|
||||
String configToImport) {
|
||||
if (!getConfigImporters().containsKey(importerName)) {
|
||||
return ConfigEditorResult.fromMessage(ConfigEditorResult.StatusCode.BAD_REQUEST,
|
||||
ErrorMessages.UNKNOWN_CONFIG_IMPORTER.getMessage(importerName));
|
||||
@@ -67,18 +126,38 @@ public interface ConfigSchemaService extends HealthCheckable {
|
||||
return importResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a json schema for an admin configuration
|
||||
* @return a config editor result with a json schema for an admin configuration
|
||||
*/
|
||||
default ConfigEditorResult getAdminConfigurationSchema() {
|
||||
return ConfigEditorResult.fromMessage(ConfigEditorResult.StatusCode.ERROR, NOT_IMPLEMENTED_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an admin configuration
|
||||
* @param configuration a json string with an admin configuration
|
||||
* @return a config editor result with OK status code if the admin configuration is valid, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
default ConfigEditorResult validateAdminConfiguration(String configuration) {
|
||||
return ConfigEditorResult.fromMessage(ConfigEditorResult.StatusCode.ERROR, NOT_IMPLEMENTED_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a topology name from an admin configuration
|
||||
* @param configuration a json string with an admin configuration
|
||||
* @return a config editor result with the topology name on success, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
default ConfigEditorResult getAdminConfigTopologyName(String configuration) {
|
||||
return ConfigEditorResult.fromMessage(ConfigEditorResult.StatusCode.ERROR, NOT_IMPLEMENTED_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a config schema service with enhanced error messages
|
||||
* @return a config schema service with enhanced error messages
|
||||
*/
|
||||
default ConfigSchemaService withErrorMessage() {
|
||||
return new ConfigSchemaServiceWithErrorMessage(this);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,16 @@ import uk.co.gresearch.siembol.configeditor.model.ErrorTitles;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An object for configuration schema service with enhanced error messages
|
||||
*
|
||||
* <p>This class implements ConfigSchemaService interface, and it extends ServiceWithErrorMessage class.
|
||||
* It enriches error messages on error.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ServiceWithErrorMessage
|
||||
* @see ConfigSchemaService
|
||||
*/
|
||||
public class ConfigSchemaServiceWithErrorMessage extends ServiceWithErrorMessage<ConfigSchemaService>
|
||||
implements ConfigSchemaService {
|
||||
|
||||
@@ -16,11 +25,17 @@ public class ConfigSchemaServiceWithErrorMessage extends ServiceWithErrorMessage
|
||||
super(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getSchema() {
|
||||
return service.getSchema();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validateConfiguration(String configuration) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.validateConfiguration(configuration);
|
||||
@@ -29,6 +44,9 @@ public class ConfigSchemaServiceWithErrorMessage extends ServiceWithErrorMessage
|
||||
ErrorResolutions.VALIDATION.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validateConfigurations(String configurations) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.validateConfigurations(configurations);
|
||||
@@ -37,31 +55,49 @@ public class ConfigSchemaServiceWithErrorMessage extends ServiceWithErrorMessage
|
||||
ErrorResolutions.VALIDATION.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, ConfigImporter> getConfigImporters() {
|
||||
return service.getConfigImporters();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigTesters() {
|
||||
return service.getConfigTesters();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigTester getConfigTester(String name) {
|
||||
return service.getConfigTester(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Health checkHealth() {
|
||||
return service.checkHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getImporters() {
|
||||
return service.getImporters();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult importConfig(UserInfo user,
|
||||
String importerName,
|
||||
@@ -74,11 +110,17 @@ public class ConfigSchemaServiceWithErrorMessage extends ServiceWithErrorMessage
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfigurationSchema() {
|
||||
return service.getAdminConfigurationSchema();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validateAdminConfiguration(String configuration) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.validateAdminConfiguration(configuration);
|
||||
@@ -87,6 +129,9 @@ public class ConfigSchemaServiceWithErrorMessage extends ServiceWithErrorMessage
|
||||
ErrorResolutions.VALIDATION.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfigTopologyName(String configuration) {
|
||||
return service.getAdminConfigTopologyName(configuration);
|
||||
|
||||
@@ -4,17 +4,39 @@ import uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigTesterDto;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* An object for testing configurations
|
||||
*
|
||||
* <p>This interface is for providing functionality for testing configurations.
|
||||
* Moreover, it validates a test specification and provides the test specification schema.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface ConfigTester {
|
||||
String DEFAULT_NAME = "default";
|
||||
String NOT_SUPPORTED_MSG = "This type of testing is not supported";
|
||||
|
||||
/**
|
||||
* Gets the name of the tester
|
||||
* @return the name of teh tester
|
||||
*/
|
||||
default String getName() {
|
||||
return DEFAULT_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tester flags
|
||||
* @return the set of test flags
|
||||
* @see ConfigTesterFlag
|
||||
*/
|
||||
EnumSet<ConfigTesterFlag> getFlags();
|
||||
|
||||
/**
|
||||
* Gets tester information
|
||||
* @return config tester info object
|
||||
* @see ConfigTesterDto
|
||||
*/
|
||||
default ConfigTesterDto getConfigTesterInfo() {
|
||||
var ret = new ConfigTesterDto();
|
||||
ret.setName(getName());
|
||||
@@ -27,18 +49,46 @@ public interface ConfigTester {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tester specification schema
|
||||
* @return config editor result with a test specification json schema
|
||||
*/
|
||||
ConfigEditorResult getTestSpecificationSchema();
|
||||
|
||||
/**
|
||||
* Validates test specification
|
||||
* @param attributes a json string with test specification
|
||||
* @return config editor result with OK status code if the specification is valid, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
ConfigEditorResult validateTestSpecification(String attributes);
|
||||
|
||||
/**
|
||||
* Tests a configuration against a test specification
|
||||
* @param configuration a json string with configuration
|
||||
* @param testSpecification a json string with test specification
|
||||
* @return a config editor result with test result if the test was successful, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
default ConfigEditorResult testConfiguration(String configuration, String testSpecification) {
|
||||
return ConfigEditorResult.fromMessage(ConfigEditorResult.StatusCode.BAD_REQUEST, NOT_SUPPORTED_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a configurations against a test specification
|
||||
* @param configurations a json string with configurations
|
||||
* @param testSpecification a json string with test specification
|
||||
* @return a config editor result with test result if the test was successful, otherwise
|
||||
* the result with ERROR status.
|
||||
*/
|
||||
default ConfigEditorResult testConfigurations(String configurations, String testSpecification) {
|
||||
return ConfigEditorResult.fromMessage(ConfigEditorResult.StatusCode.BAD_REQUEST, NOT_SUPPORTED_MSG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a config tester with enhanced error messages
|
||||
* @return a config tester with enhanced error messages
|
||||
*/
|
||||
default ConfigTester withErrorMessage() {
|
||||
return new ConfigTesterWithErrorMessage(this);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,13 @@ package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
import uk.co.gresearch.siembol.common.jsonschema.SiembolJsonSchemaValidator;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult;
|
||||
|
||||
/**
|
||||
* An object that provides base functionality for a config tester
|
||||
*
|
||||
* <p>This abstract class implements ConfigTester interface and provides common functionality for all config testers.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public abstract class ConfigTesterBase<T> implements ConfigTester {
|
||||
private final SiembolJsonSchemaValidator testValidator;
|
||||
|
||||
@@ -16,11 +22,17 @@ public abstract class ConfigTesterBase<T> implements ConfigTester {
|
||||
this.testProvider = testProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getTestSpecificationSchema() {
|
||||
return ConfigEditorResult.fromTestSchema(testSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validateTestSpecification(String attributes) {
|
||||
var validateResult = testValidator.validate(attributes);
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
/**
|
||||
* An enum of config tester flags
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see #CONFIG_TESTING
|
||||
* @see #TEST_CASE_TESTING
|
||||
* @see #RELEASE_TESTING
|
||||
* @see #INCOMPLETE_RESULT
|
||||
*/
|
||||
public enum ConfigTesterFlag {
|
||||
CONFIG_TESTING,
|
||||
TEST_CASE_TESTING,
|
||||
|
||||
@@ -7,22 +7,40 @@ import uk.co.gresearch.siembol.configeditor.model.ErrorTitles;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An object for configuration tester with enhanced error messages
|
||||
*
|
||||
* <p>This class implements ConfigTester interface, and it extends ServiceWithErrorMessage class.
|
||||
* It enriches error messages on error.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ServiceWithErrorMessage
|
||||
* @see ConfigTester
|
||||
*/
|
||||
public class ConfigTesterWithErrorMessage extends ServiceWithErrorMessage<ConfigTester> implements ConfigTester {
|
||||
public ConfigTesterWithErrorMessage(ConfigTester service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EnumSet<ConfigTesterFlag> getFlags() {
|
||||
return service.getFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getTestSpecificationSchema() {
|
||||
return service.getTestSpecificationSchema();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validateTestSpecification(String attributes) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.validateTestSpecification(attributes);
|
||||
@@ -31,6 +49,9 @@ public class ConfigTesterWithErrorMessage extends ServiceWithErrorMessage<Confi
|
||||
ErrorResolutions.VALIDATION.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult testConfiguration(String configuration, String testSpecification) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.testConfiguration(configuration, testSpecification);
|
||||
@@ -39,6 +60,9 @@ public class ConfigTesterWithErrorMessage extends ServiceWithErrorMessage<Confi
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult testConfigurations(String configurations, String testSpecification) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.testConfigurations(configurations, testSpecification);
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* An enum of service user roles
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see #SERVICE_ADMIN
|
||||
* @see #SERVICE_USER
|
||||
*/
|
||||
public enum ServiceUserRole {
|
||||
@JsonProperty("service_user") SERVICE_USER("service_user"),
|
||||
@JsonProperty("service_admin") SERVICE_ADMIN("service_admin");
|
||||
|
||||
@@ -3,7 +3,13 @@ package uk.co.gresearch.siembol.configeditor.common;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An object that enhances error messages for a service
|
||||
*
|
||||
* <p>This class provides functionality for enhancing error messages for a generic service.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ServiceWithErrorMessage<T> {
|
||||
protected final T service;
|
||||
|
||||
|
||||
@@ -2,7 +2,14 @@ package uk.co.gresearch.siembol.configeditor.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An object that represents information about a user
|
||||
*
|
||||
* <p>This class represents information about user such as the name, email address and groups that the user belongs to.
|
||||
* Moreover, it includes the user role under which is trying to access Siembol services.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class UserInfo {
|
||||
private String userName;
|
||||
private String email;
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
package uk.co.gresearch.siembol.configeditor.configinfo;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An object for providing metadata about a json admin configuration change
|
||||
*
|
||||
* <p>This class implements ConfigInfoProvider interface. It provides metadata about a json admin configuration change.
|
||||
* It provides information such as the author of the change, type of change, and the version of the admin configuration.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ConfigInfoProvider
|
||||
*
|
||||
*/
|
||||
public class AdminConfigInfoProvider implements ConfigInfoProvider {
|
||||
private static final String UNSUPPORTED_MESSAGE = "Not supported operation";
|
||||
private static final String ADMIN_CONFIG_FILE_NAME = "admin_config.json";
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
package uk.co.gresearch.siembol.configeditor.common;
|
||||
package uk.co.gresearch.siembol.configeditor.configinfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorFile;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* An object for providing metadata about a configuration change
|
||||
*
|
||||
* <p>This interface is for providing metadata about a configuration change.
|
||||
* It provides information such as the author of the change, type of change, and the version of the configuration.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface ConfigInfoProvider {
|
||||
String RELEASE_BRANCH_TEMPLATE = "ver_%d_by_%s_on_%s";
|
||||
String MISSING_ARGUMENTS_MSG = "missing user info attributes";
|
||||
@@ -13,8 +24,22 @@ public interface ConfigInfoProvider {
|
||||
int MILLI_SECONDS = 1000;
|
||||
int INIT_RELEASE_VERSION = 0;
|
||||
|
||||
/**
|
||||
* Gets the config info
|
||||
* @param user a user info object
|
||||
* @param config a json string with configuration
|
||||
* @return a config info object
|
||||
* @see ConfigInfo
|
||||
*/
|
||||
ConfigInfo getConfigInfo(UserInfo user, String config);
|
||||
|
||||
/**
|
||||
* Gets the config info for a default user
|
||||
*
|
||||
* @param config a json string with configuration
|
||||
* @return a config info object
|
||||
* @see ConfigInfo
|
||||
*/
|
||||
default ConfigInfo getConfigInfo(String config) {
|
||||
UserInfo unknownUser = new UserInfo();
|
||||
unknownUser.setUserName(UNKNOWN_USER_INFO);
|
||||
@@ -22,14 +47,42 @@ public interface ConfigInfoProvider {
|
||||
return getConfigInfo(unknownUser, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a release info
|
||||
* @param user a user info object
|
||||
* @param release a json string with a release
|
||||
* @return a config info object
|
||||
* @see ConfigInfo
|
||||
*/
|
||||
ConfigInfo getReleaseInfo(UserInfo user, String release);
|
||||
|
||||
/**
|
||||
* Gets a release version from a list of files
|
||||
* @param files the list of files
|
||||
* @return version of the release
|
||||
*/
|
||||
int getReleaseVersion(List<ConfigEditorFile> files);
|
||||
|
||||
/**
|
||||
* Gets a release version from a release file
|
||||
* @param content a json string with release
|
||||
* @return version of the release
|
||||
*/
|
||||
int getReleaseVersion(String content);
|
||||
|
||||
/**
|
||||
* Gets information whether the config is included in the release
|
||||
* @param release a json string with release
|
||||
* @param configName teh name of config to check
|
||||
* @return true if the config is included in the release, otherwise false
|
||||
*/
|
||||
boolean isConfigInRelease(String release, String configName);
|
||||
|
||||
/**
|
||||
* Gets file content type
|
||||
* @return the content type of the config file
|
||||
* @see ConfigEditorFile.ContentType
|
||||
*/
|
||||
ConfigEditorFile.ContentType getFileContentType();
|
||||
|
||||
default ConfigInfo configInfoFromUser(UserInfo user) {
|
||||
@@ -63,5 +116,10 @@ public interface ConfigInfoProvider {
|
||||
return INIT_RELEASE_VERSION == version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets config info type
|
||||
* @return config info type for a configuration
|
||||
* @see ConfigInfoType
|
||||
*/
|
||||
ConfigInfoType getConfigInfoType();
|
||||
}
|
||||
@@ -16,7 +16,16 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* An object for providing metadata about a json configuration change
|
||||
*
|
||||
* <p>This class implements ConfigInfoProvider interface. It provides metadata about a json configuration change.
|
||||
* It provides information such as the author of the change, type of change, and the version of the configuration.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ConfigInfoProvider
|
||||
*
|
||||
*/
|
||||
public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private static final String RULE_COMMIT_TEMPLATE_NEW = "Adding new %s: %s";
|
||||
@@ -79,6 +88,9 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
this.jsonPathConfigNameSearch = String.format(JSON_PATH_FIELD_SEARCH_FORMAT, configNameField);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigInfo getConfigInfo(UserInfo user, String config) {
|
||||
ConfigInfo configInfo = configInfoFromUser(user);
|
||||
@@ -138,6 +150,9 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
return configInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigInfo getReleaseInfo(UserInfo user, String release) {
|
||||
ConfigInfo configInfo = configInfoFromUser(user);
|
||||
@@ -166,6 +181,9 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
return configInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getReleaseVersion(String content) {
|
||||
Map<String, Object> metadata;
|
||||
@@ -184,6 +202,9 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
return ((Number)metadata.get(configsVersionField)).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isConfigInRelease(String release, String configName) {
|
||||
JsonNode configsNode = ConfigEditorUtils.evaluateJsonPath(release, jsonPathConfigNameSearch);
|
||||
@@ -196,6 +217,9 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getReleaseVersion(List<ConfigEditorFile> files) {
|
||||
Optional<ConfigEditorFile> release = files
|
||||
@@ -210,21 +234,33 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
return getReleaseVersion(release.get().getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorFile.ContentType getFileContentType() {
|
||||
return ConfigEditorFile.ContentType.RAW_JSON_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isStoreFile(String filename) {
|
||||
return filename.endsWith(jsonFileSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isReleaseFile(String filename) {
|
||||
return releaseFilename.equals(filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigInfoType getConfigInfoType() {
|
||||
return configType;
|
||||
@@ -262,6 +298,11 @@ public class JsonConfigInfoProvider implements ConfigInfoProvider {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a json config info provider
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public static class Builder {
|
||||
private static final String COMMIT_TEMPLATE_NEW = "Adding new %s: %%s";
|
||||
private static final String COMMIT_TEMPLATE_UPDATE = "Updating %s: %%s to version: %%d";
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package uk.co.gresearch.siembol.configeditor.configinfo;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
|
||||
/**
|
||||
* An object for providing metadata about a json rule change
|
||||
*
|
||||
* <p>This class implements ConfigInfoProvider interface. It provides metadata about a json rule change.
|
||||
* It provides information such as the author of the change, type of change, and the version of the configuration.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ConfigInfoProvider
|
||||
*
|
||||
*/
|
||||
public class JsonRuleConfigInfoProvider {
|
||||
private static final String AUTHOR_FIELD = "rule_author";
|
||||
private static final String NAME_FIELD = "rule_name";
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
package uk.co.gresearch.siembol.configeditor.configinfo;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorFile;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An object for providing metadata about a json test case change
|
||||
*
|
||||
* <p>This class implements ConfigInfoProvider interface. It provides metadata about a json test case change.
|
||||
* It provides information such as the author of the change, type of change, and the version of the test case.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ConfigInfoProvider
|
||||
*
|
||||
*/
|
||||
public class TestCaseInfoProvider implements ConfigInfoProvider {
|
||||
private static final String UNSUPPORTED_MESSAGE = "Not supported operation";
|
||||
private static final String AUTHOR_FIELD = "author";
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.git.GitRepository;
|
||||
import uk.co.gresearch.siembol.configeditor.model.*;
|
||||
@@ -18,7 +18,15 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.BAD_REQUEST;
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.OK;
|
||||
|
||||
/**
|
||||
* An object that represents a config and a test case
|
||||
*
|
||||
* <p>This class represents a config and a test case.
|
||||
* It implements common logic for both types of configurations.
|
||||
* It is used in ConfigStoreImpl.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ConfigItems {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private static final String INIT_START = "Trying Initialise a git repository: {}";
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import uk.co.gresearch.siembol.configeditor.common.*;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.git.GitRepository;
|
||||
import uk.co.gresearch.siembol.configeditor.git.ReleasePullRequestService;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorFile;
|
||||
@@ -17,7 +18,15 @@ import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.OK;
|
||||
|
||||
/**
|
||||
* An object that represents a config release and an admin config
|
||||
*
|
||||
* <p>This class represents a config release and an admin config.
|
||||
* It implements common logic for both types of configurations.
|
||||
* It is used in ConfigStoreImpl.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ConfigRelease {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private static final String SUBMIT_INIT_LOG_MSG = "User: {} trying to release {} version: {}";
|
||||
|
||||
@@ -4,44 +4,147 @@ import org.springframework.boot.actuate.health.Health;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult;
|
||||
import uk.co.gresearch.siembol.configeditor.common.HealthCheckable;
|
||||
|
||||
/**
|
||||
* An object for storing and manipulating Siembol configurations
|
||||
*
|
||||
* <p>This interface is for storing and manipulating Siembol configurations.
|
||||
* It stores configurations, test cases, an admin config and the release.
|
||||
* It checks health of the service.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface ConfigStore extends HealthCheckable {
|
||||
/**
|
||||
* Adds a test case into the store
|
||||
* @param user the metadata about the user
|
||||
* @param testCase a json string test case
|
||||
* @return config editor result with the status and the files after adding the test cases
|
||||
*/
|
||||
ConfigEditorResult addTestCase(UserInfo user, String testCase);
|
||||
|
||||
/**
|
||||
* Updates an existing test case in the store
|
||||
* @param user the metadata about the user
|
||||
* @param testCase a json string test case
|
||||
* @return config editor result with the status and the files after updating the test cases
|
||||
*/
|
||||
ConfigEditorResult updateTestCase(UserInfo user, String testCase);
|
||||
|
||||
/**
|
||||
* Deletes existing test case in the store
|
||||
* @param user the metadata about the user
|
||||
* @param configName the name of configuration of the test case
|
||||
* @param testCaseName the name of teh test case to be deleted
|
||||
* @return config editor result with the status and the files after updating the test cases
|
||||
*/
|
||||
ConfigEditorResult deleteTestCase(UserInfo user, String configName, String testCaseName);
|
||||
|
||||
/**
|
||||
* Gets test cases from the store
|
||||
* @return config editor result with test cases files
|
||||
*/
|
||||
ConfigEditorResult getTestCases();
|
||||
|
||||
/**
|
||||
* Adds a configuration into the store
|
||||
* @param user the metadata about the user
|
||||
* @param newConfig a json string configuration
|
||||
* @return config editor result with the status and the files after adding the configuration
|
||||
*/
|
||||
ConfigEditorResult addConfig(UserInfo user, String newConfig);
|
||||
|
||||
/**
|
||||
* Updates a configuration in the store
|
||||
* @param user the metadata about the user
|
||||
* @param configToUpdate a json string configuration
|
||||
* @return config editor result with the status and the files after updating the configuration
|
||||
*/
|
||||
ConfigEditorResult updateConfig(UserInfo user, String configToUpdate);
|
||||
|
||||
/**
|
||||
* Deletes existing test case in the store
|
||||
* @param user the metadata about the user
|
||||
* @param configName the name of configuration to be deleted
|
||||
* @return config editor result with the status and the files after deleting
|
||||
*/
|
||||
ConfigEditorResult deleteConfig(UserInfo user, String configName);
|
||||
|
||||
/**
|
||||
* Gets configurations from the store
|
||||
* @return config editor result with configuration files
|
||||
*/
|
||||
ConfigEditorResult getConfigs();
|
||||
|
||||
/**
|
||||
* Gets the release form the cache
|
||||
* @return config editor result with the release file
|
||||
*/
|
||||
ConfigEditorResult getConfigsReleaseFromCache();
|
||||
|
||||
/**
|
||||
* Gets the release form the store
|
||||
* @return config editor result with the release file
|
||||
*/
|
||||
ConfigEditorResult getConfigsRelease();
|
||||
|
||||
/**
|
||||
* Gets the release status related to pending pull requests
|
||||
* @return config editor result with the release status
|
||||
*/
|
||||
ConfigEditorResult getConfigsReleaseStatus();
|
||||
|
||||
/**
|
||||
* Submits the release into the store
|
||||
* @param user the metadata about the user
|
||||
* @param rulesRelease a json string with the release
|
||||
* @return config editor result with the release status
|
||||
*/
|
||||
ConfigEditorResult submitConfigsRelease(UserInfo user, String rulesRelease);
|
||||
|
||||
/**
|
||||
* Gets the admin configuration form the cache
|
||||
* @return config editor result with the admin configuration file
|
||||
*/
|
||||
ConfigEditorResult getAdminConfigFromCache();
|
||||
|
||||
/**
|
||||
* Gets the admin configuration form the store
|
||||
* @return config editor result with the admin configuration file
|
||||
*/
|
||||
ConfigEditorResult getAdminConfig();
|
||||
|
||||
/**
|
||||
* Gets the admin configuration status related to pending pull requests
|
||||
* @return config editor result with the admin configuration status
|
||||
*/
|
||||
ConfigEditorResult getAdminConfigStatus();
|
||||
|
||||
/**
|
||||
* Submits the admin configuration into the store
|
||||
* @param user the metadata about the user
|
||||
* @param adminConfig a json string with the admin configuration
|
||||
* @return config editor result with the admin configuration status
|
||||
*/
|
||||
ConfigEditorResult submitAdminConfig(UserInfo user, String adminConfig);
|
||||
|
||||
/**
|
||||
* Gets urls to all store repositories
|
||||
* @return the config editor result with urls to all store repositories
|
||||
*/
|
||||
ConfigEditorResult getRepositories();
|
||||
|
||||
/**
|
||||
* Checks the health of the store
|
||||
* @return an health object with the status information
|
||||
* @see Health
|
||||
*/
|
||||
Health checkHealth();
|
||||
|
||||
/**
|
||||
* Gets an store instance with enhanced error message
|
||||
* @return
|
||||
*/
|
||||
default ConfigStore withErrorMessage() {
|
||||
return new ConfigStoreWithErrorMessage(this);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigEditorUtils;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.AdminConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.TestCaseInfoProvider;
|
||||
@@ -22,7 +22,21 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.ERROR;
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.OK;
|
||||
|
||||
/**
|
||||
* An object for storing and manipulating Siembol configurations
|
||||
*
|
||||
* <p>This class implements ConfigStore interface is for storing and manipulating Siembol configurations.
|
||||
* It is using GitRepository for storing configurations and ReleasePullRequestService for submitting a release and admin config.
|
||||
* It stores configurations, test cases, an admin config and the release.
|
||||
* It checks health of the service.
|
||||
* All store operations are executed in dedicated threads in order to avoid concurrency issues.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ConfigStore
|
||||
* @see GitRepository
|
||||
* @see ReleasePullRequestService
|
||||
*
|
||||
*/
|
||||
public class ConfigStoreImpl implements ConfigStore {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private static final String TEST_CASES_UNSUPPORTED_MSG = "Test cases are not supported";
|
||||
@@ -50,6 +64,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
this.adminConfig = builder.adminConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult addTestCase(UserInfo user, String testCase) {
|
||||
if (testCases == null) {
|
||||
@@ -60,6 +77,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(command, storeExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult updateTestCase(UserInfo user, String testCase) {
|
||||
if (testCases == null) {
|
||||
@@ -70,6 +90,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(command, storeExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult deleteTestCase(UserInfo user, String configName, String testCaseName) {
|
||||
if (testCases == null) {
|
||||
@@ -81,6 +104,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(command, storeExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getTestCases() {
|
||||
if (testCases == null) {
|
||||
@@ -93,18 +119,27 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return testCases.getFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult addConfig(UserInfo user, String newConfig) {
|
||||
Callable<ConfigEditorResult> command = () -> configs.addConfigItem(user, newConfig);
|
||||
return executeStoreCommand(command, storeExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult updateConfig(UserInfo user, String configToUpdate) {
|
||||
Callable<ConfigEditorResult> command = () -> configs.updateConfigItem(user, configToUpdate);
|
||||
return executeStoreCommand(command, storeExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult deleteConfig(UserInfo user, String configName) {
|
||||
Callable<ConfigEditorResult> releaseCheckCommand = () -> release.checkConfigNotInRelease(configName);
|
||||
@@ -136,6 +171,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(deleteCommand, storeExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigs() {
|
||||
if (exception.get() != null) {
|
||||
@@ -145,6 +183,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return configs.getFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigsReleaseFromCache() {
|
||||
if (exception.get() != null) {
|
||||
@@ -154,24 +195,36 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return release.getConfigsReleaseFromCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigsRelease() {
|
||||
Callable<ConfigEditorResult> command = release::getConfigsRelease;
|
||||
return executeStoreCommand(command, releaseExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigsReleaseStatus() {
|
||||
Callable<ConfigEditorResult> command = release::getConfigsReleaseStatus;
|
||||
return executeStoreCommand(command, releaseExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult submitConfigsRelease(UserInfo user, String rulesRelease) {
|
||||
Callable<ConfigEditorResult> command = () -> release.submitConfigsRelease(user, rulesRelease);
|
||||
return executeStoreCommand(command, releaseExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfigFromCache() {
|
||||
if (adminConfig == null) {
|
||||
@@ -185,6 +238,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return adminConfig.getConfigsReleaseFromCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfig() {
|
||||
if (adminConfig == null) {
|
||||
@@ -195,6 +251,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(command, adminConfigExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfigStatus() {
|
||||
if (adminConfig == null) {
|
||||
@@ -205,6 +264,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(command, adminConfigExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult submitAdminConfig(UserInfo user, String adminConfigStr) {
|
||||
if (adminConfig == null) {
|
||||
@@ -215,6 +277,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return executeStoreCommand(command, adminConfigExecutorService);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getRepositories() {
|
||||
ConfigEditorRepositories repositories = new ConfigEditorRepositories();
|
||||
@@ -239,6 +304,9 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
return new ConfigEditorResult(OK, attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Health checkHealth() {
|
||||
Exception e = exception.get();
|
||||
@@ -267,6 +335,11 @@ public class ConfigStoreImpl implements ConfigStore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a config store
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public static class Builder {
|
||||
private static final ConfigInfoProvider TEST_CASE_INFO_PROVIDER = new TestCaseInfoProvider();
|
||||
private static final ConfigInfoProvider ADMIN_CONFIG_INFO_PROVIDER = new AdminConfigInfoProvider();
|
||||
|
||||
@@ -9,12 +9,25 @@ import uk.co.gresearch.siembol.configeditor.model.ErrorResolutions;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ErrorTitles;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An object for storing and manipulating Siembol configurations with enhanced error messages
|
||||
*
|
||||
* <p>This class implements ConfigStore interface and it extends ServiceWithErrorMessage class.
|
||||
* It enriches error messages on error.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ServiceWithErrorMessage
|
||||
* @see ConfigStore
|
||||
*
|
||||
*/
|
||||
public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigStore> implements ConfigStore {
|
||||
public ConfigStoreWithErrorMessage(ConfigStore service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult addTestCase(UserInfo user, String testCase) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.addTestCase(user, testCase);
|
||||
@@ -23,6 +36,9 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult updateTestCase(UserInfo user, String testCase) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.updateTestCase(user, testCase);
|
||||
@@ -31,6 +47,9 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult deleteTestCase(UserInfo user, String configName, String testCaseName) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.deleteTestCase(user, configName, testCaseName);
|
||||
@@ -39,11 +58,17 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getTestCases() {
|
||||
return service.getTestCases();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult addConfig(UserInfo user, String newConfig) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.addConfig(user, newConfig);
|
||||
@@ -52,6 +77,9 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult updateConfig(UserInfo user, String configToUpdate) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.updateConfig(user, configToUpdate);
|
||||
@@ -60,6 +88,9 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult deleteConfig(UserInfo user, String configName) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.deleteConfig(user, configName);
|
||||
@@ -68,26 +99,41 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigs() {
|
||||
return service.getConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigsReleaseFromCache() {
|
||||
return service.getConfigsReleaseFromCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigsRelease() {
|
||||
return service.getConfigsRelease();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getConfigsReleaseStatus() {
|
||||
return service.getConfigsReleaseStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult submitConfigsRelease(UserInfo user, String rulesRelease) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.submitConfigsRelease(user, rulesRelease);
|
||||
@@ -96,6 +142,9 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfigFromCache() {
|
||||
return service.getAdminConfigFromCache();
|
||||
@@ -106,11 +155,17 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
return service.getAdminConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getAdminConfigStatus() {
|
||||
return service.getAdminConfigStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult submitAdminConfig(UserInfo user, String adminConfig) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.submitAdminConfig(user, adminConfig);
|
||||
@@ -119,11 +174,17 @@ public class ConfigStoreWithErrorMessage extends ServiceWithErrorMessage<ConfigS
|
||||
ErrorResolutions.GENERIC_BAD_REQUEST.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getRepositories() {
|
||||
return service.getRepositories();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Health checkHealth() {
|
||||
return service.checkHealth();
|
||||
|
||||
@@ -26,7 +26,16 @@ import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* An object for interaction with a git repository
|
||||
*
|
||||
*
|
||||
* <p>This class implements Closeable interface.
|
||||
* It is used for cloning the repository, committing a change in a git repository and
|
||||
* for obtaining the current files including the history of changes.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class GitRepository implements Closeable {
|
||||
private static final String MISSING_ARGUMENTS_MSG = "Missing arguments required for git repository initialisation";
|
||||
private static final String ERROR_INIT_MSG = "Error during git repository initialisation";
|
||||
@@ -63,6 +72,16 @@ public class GitRepository implements Closeable {
|
||||
defaultBranch = builder.defaultBranch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies and commits the files in the repository
|
||||
*
|
||||
* @param configInfo metadata such as a git branch, an author and files to be copied and committed
|
||||
* @param directory the directory where the files should be copied
|
||||
* @param fileNameFilter the filter for filtering the files to be included in the result
|
||||
* @return a config editor result with the current files in the repository
|
||||
* @throws GitAPIException
|
||||
* @throws IOException
|
||||
*/
|
||||
public ConfigEditorResult transactCopyAndCommit(
|
||||
ConfigInfo configInfo,
|
||||
String directory,
|
||||
@@ -131,10 +150,25 @@ public class GitRepository implements Closeable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current files from a directory
|
||||
* @param directory a folder name
|
||||
* @return a config editor result with the current files in the repository under the directory
|
||||
* @throws IOException
|
||||
* @throws GitAPIException
|
||||
*/
|
||||
public ConfigEditorResult getFiles(String directory) throws IOException, GitAPIException {
|
||||
return getFiles(directory, x -> true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current files from a directory
|
||||
* @param directory a folder name
|
||||
* @param fileNameFilter a filter for filtering the files
|
||||
* @return a config editor result with the current files in the repository under the directory
|
||||
* @throws IOException
|
||||
* @throws GitAPIException
|
||||
*/
|
||||
public ConfigEditorResult getFiles(String directory,
|
||||
Function<String, Boolean> fileNameFilter) throws IOException, GitAPIException {
|
||||
git.pull()
|
||||
@@ -203,23 +237,43 @@ public class GitRepository implements Closeable {
|
||||
return new ConfigEditorResult(ConfigEditorResult.StatusCode.OK, attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a git repository URL
|
||||
* @return a git repository URL
|
||||
*/
|
||||
public String getRepoUri() {
|
||||
return repoUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a git repository URL with a directory
|
||||
* @return a git repository URL with a directory
|
||||
*/
|
||||
public String getDirectoryUrl(String directory) {
|
||||
return String.format(GIT_REPO_DIRECTORY_URL_FORMAT, gitUrl, repoName, defaultBranch, directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default branch computed during initialisatio
|
||||
* @return the default branch name
|
||||
*/
|
||||
public String getDefaultBranch() {
|
||||
return defaultBranch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the repository
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
git.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a git repository
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public static class Builder {
|
||||
private static final String GIT_REPO_URL_FORMAT = "%s/%s.git";
|
||||
private String repoName;
|
||||
@@ -231,26 +285,53 @@ public class GitRepository implements Closeable {
|
||||
private Git git;
|
||||
private ConfigEditorFile.ContentType contentType = ConfigEditorFile.ContentType.RAW_JSON_STRING;
|
||||
|
||||
/**
|
||||
* Sets the repository name
|
||||
* @param repoName the name of teh repository
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder repoName(String repoName) {
|
||||
this.repoName = repoName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets git url
|
||||
* @param gitUrl a url to git server
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder gitUrl(String gitUrl) {
|
||||
this.gitUrl = gitUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets folder for this repository to be considered.
|
||||
* @param repoFolder the name of the folder
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder repoFolder(String repoFolder) {
|
||||
this.repoFolder = repoFolder;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the credentials for the git repository
|
||||
* @param userName the name of the user
|
||||
* @param password password or PAT
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder credentials(String userName, String password) {
|
||||
credentialsProvider = new UsernamePasswordCredentialsProvider(userName, password);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the git repository
|
||||
* @return the git repository built from the builder state
|
||||
* @throws GitAPIException
|
||||
* @throws IOException
|
||||
*/
|
||||
public GitRepository build() throws GitAPIException, IOException {
|
||||
if (repoName == null
|
||||
|| gitUrl == null
|
||||
|
||||
@@ -11,7 +11,15 @@ import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An object for interaction with a GitHub API
|
||||
*
|
||||
*
|
||||
* <p>This class is used for interaction with a GitHub API in order to create a pull request and
|
||||
* checks for opened pull request in the repository.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ReleasePullRequestService {
|
||||
private static final String BODY_TEMPLATE = "User %s would like to release %s version %d.";
|
||||
private static final String PR_STATE_OPEN = "open";
|
||||
@@ -27,6 +35,12 @@ public class ReleasePullRequestService {
|
||||
this.branchTo = builder.branchTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a pull request
|
||||
* @param info metadata about the pull request
|
||||
* @return the config editor result with pull request status
|
||||
* @throws IOException
|
||||
*/
|
||||
public ConfigEditorResult createPullRequest(ConfigInfo info) throws IOException {
|
||||
PullRequest request = new PullRequest();
|
||||
request.setBody(String.format(BODY_TEMPLATE,
|
||||
@@ -44,6 +58,11 @@ public class ReleasePullRequestService {
|
||||
return new ConfigEditorResult(ConfigEditorResult.StatusCode.OK, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets info about pending pull request in the repository
|
||||
* @return the config editor result with a pending pull request flag
|
||||
* @throws IOException
|
||||
*/
|
||||
public ConfigEditorResult pendingPullRequest() throws IOException {
|
||||
List<PullRequest> requests = service.getPullRequests(repoId, PR_STATE_OPEN);
|
||||
|
||||
@@ -55,6 +74,11 @@ public class ReleasePullRequestService {
|
||||
return new ConfigEditorResult(ConfigEditorResult.StatusCode.OK, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a git repository
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public static class Builder {
|
||||
private String uri;
|
||||
private String user;
|
||||
@@ -64,27 +88,53 @@ public class ReleasePullRequestService {
|
||||
private PullRequestService service;
|
||||
private String branchTo;
|
||||
|
||||
/**
|
||||
* Sets GitHub url
|
||||
* @param uri a url to git server
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder uri(String uri) {
|
||||
this.uri = uri;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository name
|
||||
* @param repoName the name of teh repository
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder repoName(String repoName) {
|
||||
this.repoName = repoName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the credentials for the GitHub repository
|
||||
* @param user the name of the user
|
||||
* @param password password or PAT
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder credentials(String user, String password) {
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the branch name for PR to be merged into it.
|
||||
* @param branchTo the name of the branch
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder branchTo(String branchTo) {
|
||||
this.branchTo = branchTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the release pull request service
|
||||
* @return the pull request service built from the builder state
|
||||
*
|
||||
*/
|
||||
public ReleasePullRequestService build() {
|
||||
if (uri == null
|
||||
|| user == null
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package uk.co.gresearch.siembol.configeditor.model;
|
||||
|
||||
/**
|
||||
* An object that represents additional config testers
|
||||
*
|
||||
* <p>This class represents additional config testers.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class AdditionalConfigTesters {
|
||||
private SparkHdfsTesterProperties sparkHdfs;
|
||||
|
||||
|
||||
@@ -8,7 +8,15 @@ import uk.co.gresearch.siembol.common.model.StormTopologyDto;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A data transfer object that represents config editor attributes
|
||||
*
|
||||
* <p>This class represents config editor attributes.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see JsonProperty
|
||||
* @see JsonRawValue
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ConfigEditorAttributes {
|
||||
private String exception;
|
||||
|
||||
@@ -6,7 +6,16 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A data transfer object that represents config editor file
|
||||
*
|
||||
* <p>This class represents config editor file. It includes name, content and the history of modifications.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see JsonProperty
|
||||
* @see JsonRawValue
|
||||
* @see ConfigEditorFileHistoryItem
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ConfigEditorFile {
|
||||
public enum ContentType {
|
||||
|
||||
@@ -6,7 +6,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* A data transfer object that represents config editor file history item
|
||||
*
|
||||
* <p>This class represents config editor file history item.
|
||||
* It includes the author of the change, the date of the modification and number of added/removed lines.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see JsonProperty
|
||||
*/
|
||||
public class ConfigEditorFileHistoryItem {
|
||||
private String author;
|
||||
private String date;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package uk.co.gresearch.siembol.configeditor.model;
|
||||
|
||||
/**
|
||||
* An enum for representing error messages.
|
||||
* It supports formatting the message from arguments.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public enum ErrorMessages {
|
||||
CONFIG_ITEM_ALREADY_EXISTS("%s already exists"),
|
||||
CONFIG_ITEM_UNEXPECTED_VERSION("Unexpected version for %s update"),
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package uk.co.gresearch.siembol.configeditor.model;
|
||||
|
||||
/**
|
||||
* An enum for representing error messages resolutions.
|
||||
* It supports formatting the title from arguments.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public enum ErrorResolutions {
|
||||
GENERIC_BAD_REQUEST("Inspect error message and try to fix and replay your request"),
|
||||
CONCURRENT_USERS("Siembol UI can be used by multiple users in parallel. " +
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package uk.co.gresearch.siembol.configeditor.model;
|
||||
|
||||
/**
|
||||
* An enum for representing error messages titles.
|
||||
* It supports formatting the title from arguments.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public enum ErrorTitles {
|
||||
ADD_CONFIG("Problem storing configuration in git repository"),
|
||||
ADD_TEST_CASE("Problem storing test case in git repository"),
|
||||
|
||||
@@ -8,31 +8,95 @@ import uk.co.gresearch.siembol.configeditor.configstore.ConfigStore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* An object for composition of a config store service and a config schema service.
|
||||
*
|
||||
*
|
||||
* <p>This interface is for composing a config store service and a config schema service.
|
||||
* It checks an authorisation for a service and a user.
|
||||
* It checks health of all services.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface ServiceAggregator {
|
||||
/**
|
||||
* Gets a config store service for a user
|
||||
* @param user a user who is trying to access the service
|
||||
* @param serviceName the name of the service
|
||||
* @return config store service for the service
|
||||
* @throws AuthorisationException if the user is not authorised to the service
|
||||
*/
|
||||
ConfigStore getConfigStore(UserInfo user, String serviceName) throws AuthorisationException;
|
||||
|
||||
/**
|
||||
* Gets a config schema service for a user
|
||||
* @param user a user who is trying to access the service
|
||||
* @param serviceName the name of the service
|
||||
* @return config schema service for the service
|
||||
* @throws AuthorisationException if the user is not authorised to the service
|
||||
*/
|
||||
ConfigSchemaService getConfigSchema(UserInfo user, String serviceName) throws AuthorisationException;
|
||||
|
||||
/**
|
||||
* Gets a list of aggregated services
|
||||
* @return the list of aggregated services
|
||||
*/
|
||||
List<ServiceAggregatorService> getAggregatorServices();
|
||||
|
||||
/**
|
||||
* Gets a list of config store services
|
||||
* @return a list of config store services
|
||||
*/
|
||||
List<ConfigStore> getConfigStoreServices();
|
||||
|
||||
/**
|
||||
* Gets a list of config schema services
|
||||
* @return a list of config schema services
|
||||
*/
|
||||
List<ConfigSchemaService> getConfigSchemaServices();
|
||||
|
||||
/**
|
||||
* Gets a list of services for which the user is authorised
|
||||
* @param user a user info object
|
||||
* @return a list of services for which the user is authorised
|
||||
*/
|
||||
List<ConfigEditorService> getConfigEditorServices(UserInfo user);
|
||||
|
||||
/**
|
||||
* Gets a list of admin services for which the user is authorised
|
||||
* @param user a user info object
|
||||
* @return a list of services for which the user is authorised
|
||||
*/
|
||||
default List<ConfigEditorService> getConfigEditorAdminServices(UserInfo user) {
|
||||
return getConfigEditorServices(user).stream()
|
||||
.filter(x -> x.getUserRoles().contains(ServiceUserRole.SERVICE_ADMIN))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks health of all config store services
|
||||
* @return a health object with status
|
||||
* @see Health
|
||||
*/
|
||||
Health checkConfigStoreServicesHealth();
|
||||
|
||||
/**
|
||||
* Checks health of all config schema services
|
||||
* @return a health object with status
|
||||
* @see Health
|
||||
*/
|
||||
Health checkConfigSchemaServicesHealth();
|
||||
|
||||
/**
|
||||
* Initiates shutting down of all services
|
||||
* @return the result with status
|
||||
*/
|
||||
ConfigEditorResult shutDown();
|
||||
|
||||
/**
|
||||
* Waits for shutting down of all services
|
||||
* @return the result with status
|
||||
*/
|
||||
ConfigEditorResult awaitShutDown();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
import uk.co.gresearch.siembol.common.constants.ServiceType;
|
||||
import uk.co.gresearch.siembol.configeditor.common.*;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configstore.ConfigStore;
|
||||
import uk.co.gresearch.siembol.configeditor.configstore.ConfigStoreImpl;
|
||||
import uk.co.gresearch.siembol.configeditor.git.GitRepository;
|
||||
@@ -28,7 +29,20 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.OK;
|
||||
|
||||
/**
|
||||
* An object for composition of a config store service and a config schema service.
|
||||
*
|
||||
*
|
||||
* <p>This class implements ServiceAggregator and Closeable interfaces.
|
||||
* It is for composing a config store service and a config schema service.
|
||||
* It checks an authorisation for a service and a user using an authorisation provider.
|
||||
* It checks health of all services.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ServiceAggregator
|
||||
* @see AuthorisationProvider
|
||||
*
|
||||
*/
|
||||
public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
@@ -45,21 +59,33 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
this.gitRepositoriesServices = builder.gitRepositoriesServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigStore getConfigStore(UserInfo user, String serviceName) throws AuthorisationException {
|
||||
return getService(user, serviceName).getConfigStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigSchemaService getConfigSchema(UserInfo user, String serviceName) throws AuthorisationException {
|
||||
return getService(user, serviceName).getConfigSchemaService();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ServiceAggregatorService> getAggregatorServices() {
|
||||
return serviceMap.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ConfigStore> getConfigStoreServices() {
|
||||
return serviceMap.keySet().stream()
|
||||
@@ -67,6 +93,9 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ConfigSchemaService> getConfigSchemaServices() {
|
||||
return serviceMap.keySet().stream()
|
||||
@@ -74,6 +103,9 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<ConfigEditorService> getConfigEditorServices(UserInfo user) {
|
||||
List<ConfigEditorService> ret = new ArrayList<>();
|
||||
@@ -107,16 +139,25 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Health checkConfigStoreServicesHealth() {
|
||||
return checkServiceHealth(getConfigStoreServices());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Health checkConfigSchemaServicesHealth() {
|
||||
return checkServiceHealth(getConfigSchemaServices());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult shutDown() {
|
||||
LOG.info("Initiating shutting down the config store services");
|
||||
@@ -124,6 +165,9 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
return new ConfigEditorResult(OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult awaitShutDown() {
|
||||
LOG.info("Initiating awaiting shutting down the config store services");
|
||||
@@ -171,6 +215,11 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
gitRepositoriesServices.forEach(x -> x.getLeft().close());
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for a service aggregator
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public static class Builder {
|
||||
private static final String SERVICE_ALREADY_REGISTERED = "Service is already registered";
|
||||
private static final String NO_SERVICE_REGISTERED = "No services registered in aggregator";
|
||||
@@ -179,10 +228,26 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
private Map<String, Pair<GitRepository, ExecutorService>> gitRepositoriesMap = new HashMap<>();
|
||||
private List<Pair<GitRepository, ExecutorService>> gitRepositoriesServices;
|
||||
|
||||
/**
|
||||
* Creates a builder
|
||||
*
|
||||
* @param authProvider an authorisation provider for evaluating the access af a user to a service
|
||||
*/
|
||||
public Builder(AuthorisationProvider authProvider) {
|
||||
this.authProvider = authProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a service into the builder
|
||||
* @param name the name of the service
|
||||
* @param type the type of the service
|
||||
* @param configStore an already created config store for the service
|
||||
* @param schemaService an already created config schema service for the service
|
||||
* @return this builder
|
||||
* @see ServiceType
|
||||
* @see ConfigStore
|
||||
* @see ConfigSchemaService
|
||||
*/
|
||||
Builder addService(String name, ServiceType type, ConfigStore configStore, ConfigSchemaService schemaService) {
|
||||
if (serviceMap.containsKey(name)) {
|
||||
throw new IllegalArgumentException(SERVICE_ALREADY_REGISTERED);
|
||||
@@ -196,6 +261,15 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a service into the builder
|
||||
* @param name the name of the service
|
||||
* @param type the type of the service
|
||||
* @param storeProperties properties of the config store
|
||||
* @param configInfoProvider config info provider for the service
|
||||
* @param schemaService an already created config schema service for the service
|
||||
* @return this builder
|
||||
*/
|
||||
public Builder addService(String name,
|
||||
ServiceType type,
|
||||
ConfigStoreProperties storeProperties,
|
||||
@@ -205,6 +279,10 @@ public class ServiceAggregatorImpl implements ServiceAggregator, Closeable {
|
||||
return addService(name, type, configStore, schemaService);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the service aggregator built from the builder state
|
||||
*/
|
||||
public ServiceAggregator build() {
|
||||
if (serviceMap.isEmpty()) {
|
||||
throw new IllegalArgumentException(NO_SERVICE_REGISTERED);
|
||||
|
||||
@@ -5,7 +5,13 @@ import uk.co.gresearch.siembol.common.constants.ServiceType;
|
||||
import uk.co.gresearch.siembol.configeditor.configstore.ConfigStore;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.OK;
|
||||
|
||||
/**
|
||||
* An object that represents a service used in the service aggregator
|
||||
*
|
||||
* <p>This class represents a service used in the service aggregator.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*/
|
||||
public class ServiceAggregatorService {
|
||||
private final String name;
|
||||
private final ServiceType type;
|
||||
|
||||
@@ -1,15 +1,48 @@
|
||||
package uk.co.gresearch.siembol.configeditor.testcase;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult;
|
||||
|
||||
/**
|
||||
* An object for evaluating a test case
|
||||
*
|
||||
* <p>This interface is for representing a test case evaluator.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public interface TestCaseEvaluator {
|
||||
|
||||
/**
|
||||
* Evaluates a test case on a testing result
|
||||
*
|
||||
* @param jsonResult a json string with a testing result
|
||||
* @param testCase a json string with test case specification
|
||||
* @return a config editor result with a test case result on success, otherwise
|
||||
* the result with ERROR status code.
|
||||
*/
|
||||
ConfigEditorResult evaluate(String jsonResult, String testCase);
|
||||
|
||||
/**
|
||||
* Validates a test case
|
||||
*
|
||||
* @param testCase a json string with test case specification
|
||||
* @return a config editor result with OK status code if the testcase is valid, otherwise
|
||||
* the result with ERROR status code.
|
||||
*/
|
||||
ConfigEditorResult validate(String testCase);
|
||||
|
||||
/**
|
||||
* Gets json schema for a test case
|
||||
*
|
||||
* @return a config editor result with a test case json schema
|
||||
*/
|
||||
|
||||
ConfigEditorResult getSchema();
|
||||
|
||||
/**
|
||||
* Gets a test case evaluator with formatted error messages
|
||||
*
|
||||
* @return a test case evaluator with formatted error messages
|
||||
*/
|
||||
default TestCaseEvaluator withErrorMessage() {
|
||||
return new TestCaseEvaluatorWithErrorMessage(this);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,15 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static uk.co.gresearch.siembol.configeditor.model.ConfigEditorResult.StatusCode.*;
|
||||
|
||||
/**
|
||||
* An object for evaluating a test case
|
||||
*
|
||||
* <p>This class is implementing TestCaseEvaluator interface. It is used for evaluating a test case,
|
||||
* validating its syntax. Moreover, it provides json schema for a test case specification.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
*
|
||||
*/
|
||||
public class TestCaseEvaluatorImpl implements TestCaseEvaluator {
|
||||
private static final ObjectReader TEST_CASE_READER =
|
||||
new ObjectMapper().readerFor(TestCaseDto.class);
|
||||
@@ -38,6 +46,12 @@ public class TestCaseEvaluatorImpl implements TestCaseEvaluator {
|
||||
private final JsonSchemaValidator jsonSchemaValidator;
|
||||
private final String testCaseSchema;
|
||||
|
||||
/**
|
||||
* Creates a test case evaluator
|
||||
* @param uiLayout a layout for enriching a test case json schema
|
||||
* @throws Exception on error
|
||||
* @see ConfigEditorUiLayout
|
||||
*/
|
||||
public TestCaseEvaluatorImpl(ConfigEditorUiLayout uiLayout) throws Exception {
|
||||
this.jsonSchemaValidator = new SiembolJsonSchemaValidator(TestCaseDto.class);
|
||||
String schemaStr = jsonSchemaValidator.getJsonSchema().getAttributes().getJsonSchema();
|
||||
@@ -92,6 +106,9 @@ public class TestCaseEvaluatorImpl implements TestCaseEvaluator {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult evaluate(String jsonResult, String testCaseJson) {
|
||||
ConfigEditorTestCaseResult testCaseResult = new ConfigEditorTestCaseResult();
|
||||
@@ -127,6 +144,9 @@ public class TestCaseEvaluatorImpl implements TestCaseEvaluator {
|
||||
return new ConfigEditorResult(OK, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validate(String testCase) {
|
||||
SiembolResult validationResult = jsonSchemaValidator.validate(testCase);
|
||||
@@ -141,6 +161,9 @@ public class TestCaseEvaluatorImpl implements TestCaseEvaluator {
|
||||
return new ConfigEditorResult(OK, new ConfigEditorAttributes());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getSchema() {
|
||||
return ConfigEditorResult.fromSchema(testCaseSchema);
|
||||
|
||||
@@ -7,13 +7,29 @@ import uk.co.gresearch.siembol.configeditor.model.ErrorResolutions;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ErrorTitles;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* An object for evaluating a test case with enhanced error messages
|
||||
*
|
||||
* <p>This class is implementing TestCaseEvaluator interface, and it extends ServiceWithErrorMessage class.
|
||||
* It is used for evaluating a test case using an underlying test case evaluator. It enriches error messages on error.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see ServiceWithErrorMessage
|
||||
* @see TestCaseEvaluator
|
||||
* @see ErrorMessages
|
||||
* @see ErrorResolutions
|
||||
* @see ErrorTitles
|
||||
*
|
||||
*/
|
||||
public class TestCaseEvaluatorWithErrorMessage extends ServiceWithErrorMessage<TestCaseEvaluator>
|
||||
implements TestCaseEvaluator {
|
||||
public TestCaseEvaluatorWithErrorMessage(TestCaseEvaluator service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult evaluate(String jsonResult, String testCase) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.evaluate(jsonResult, testCase);
|
||||
@@ -22,6 +38,9 @@ public class TestCaseEvaluatorWithErrorMessage extends ServiceWithErrorMessage<T
|
||||
ErrorResolutions.VALIDATION.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult validate(String testCase) {
|
||||
Supplier<ConfigEditorResult> fun = () -> service.validate(testCase);
|
||||
@@ -30,6 +49,9 @@ public class TestCaseEvaluatorWithErrorMessage extends ServiceWithErrorMessage<T
|
||||
ErrorResolutions.VALIDATION.getResolution());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConfigEditorResult getSchema() {
|
||||
return service.getSchema();
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package uk.co.gresearch.siembol.configeditor.testcase.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* An enum for representing an assertion type
|
||||
*
|
||||
* <p>This enum is used for json (de)serialisation of an assertion type used in a test case.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see com.fasterxml.jackson.annotation.JsonProperty
|
||||
*/
|
||||
public enum AssertionTypeDto {
|
||||
@JsonProperty("path_and_value_matches") PATH_AND_VALUE_MATCHES("path_and_value_matches"),
|
||||
@JsonProperty("only_if_path_exists") ONLY_IF_PATH_EXISTS("only_if_path_exists");
|
||||
|
||||
@@ -2,7 +2,17 @@ package uk.co.gresearch.siembol.configeditor.testcase.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.github.reinert.jjschema.Attributes;
|
||||
|
||||
/**
|
||||
* A data transfer object for representing a test assertion
|
||||
*
|
||||
* <p>This class is used for json (de)serialisation a test assertion, and
|
||||
* for generating json schema from this class using annotations.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see com.github.reinert.jjschema.Attributes
|
||||
* @see com.fasterxml.jackson.annotation.JsonProperty
|
||||
* @see AssertionTypeDto
|
||||
*/
|
||||
@Attributes(title = "test assertion", description = "Test assertion used in test case")
|
||||
public class TestAssertionDto {
|
||||
@JsonProperty("assertion_type")
|
||||
|
||||
@@ -7,7 +7,18 @@ import com.github.reinert.jjschema.SchemaIgnore;
|
||||
import uk.co.gresearch.siembol.common.model.JsonRawStringDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A data transfer object for representing a test case
|
||||
*
|
||||
* <p>This class is used for json (de)serialisation a test case, and
|
||||
* for generating json schema from this class using annotations.
|
||||
*
|
||||
* @author Marian Novotny
|
||||
* @see com.github.reinert.jjschema.Attributes
|
||||
* @see com.fasterxml.jackson.annotation.JsonProperty
|
||||
* @see JsonRawStringDto
|
||||
* @see TestAssertionDto
|
||||
*/
|
||||
@Attributes(title = "test case", description = "Test case for testing configurations")
|
||||
public class TestCaseDto {
|
||||
@JsonProperty("test_case_name")
|
||||
|
||||
@@ -3,7 +3,6 @@ package uk.co.gresearch.siembol.configeditor.configinfo;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package uk.co.gresearch.siembol.configeditor.configinfo;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorFile;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.mockito.Mockito;
|
||||
|
||||
import org.junit.Before;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.git.GitRepository;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.git.GitRepository;
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import uk.co.gresearch.siembol.common.zookeeper.ZooKeeperConnector;
|
||||
import uk.co.gresearch.siembol.common.zookeeper.ZooKeeperConnectorFactory;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.common.constants.ServiceType;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.AdminConfigInfoProvider;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package uk.co.gresearch.siembol.configeditor.service.common;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigSchemaService;
|
||||
import uk.co.gresearch.siembol.common.constants.ServiceType;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.JsonRuleConfigInfoProvider;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package uk.co.gresearch.siembol.configeditor.service.parserconfig;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.JsonConfigInfoProvider;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package uk.co.gresearch.siembol.configeditor.service.parsingapp;
|
||||
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoType;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.JsonConfigInfoProvider;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.model.ConfigEditorFile;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import uk.co.gresearch.siembol.configeditor.common.UserInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfo;
|
||||
import uk.co.gresearch.siembol.configeditor.common.ConfigInfoProvider;
|
||||
import uk.co.gresearch.siembol.configeditor.configinfo.ConfigInfoProvider;
|
||||
|
||||
public class ParsingAppConfigInfoProviderTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user