The code supports both Schema Service and local schema files.
The property schema.translator.list drives which one to use.
Change-Id: Idc9c5832d7286e7904ddf0b2637c83b0a3cfa15c
Issue-ID: AAI-2008
Signed-off-by: Ravi Geda <gravik@amdocs.com>
<properties>
<docker.location>${basedir}/target</docker.location>
- <version.org.onap.aai.aai-common>1.4.0-SNAPSHOT</version.org.onap.aai.aai-common>
+ <version.org.onap.aai.aai-common>1.4.1-SNAPSHOT</version.org.onap.aai.aai-common>
<event.client.version>1.3.1</event.client.version>
</properties>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-schema-ingest</artifactId>
<version>${version.org.onap.aai.aai-common}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.aai.aai-common</groupId>
- <artifactId>aai-core</artifactId>
- <version>${version.org.onap.aai.aai-common}</version>
<exclusions>
<exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
+ <groupId>org.powermock</groupId>
+ <artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
import java.util.Collections;
import java.util.HashMap;
-
import javax.annotation.PostConstruct;
-
import org.eclipse.jetty.util.security.Password;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
-import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.env.Environment;
-
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
*/
@SpringBootApplication
@EnableSwagger2
-@Import({SchemaIngestConfiguration.class, SchemaLoaderConfiguration.class})
@ImportResource({"file:${SERVICE_BEANS}/*.xml"})
public class CrudApplication extends SpringBootServletInitializer{// NOSONAR
@Autowired
throw new RuntimeException("Env property KEY_STORE_PASSWORD not set");
}
HashMap<String, Object> props = new HashMap<>();
- props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword));
- new CrudApplication().configure(new SpringApplicationBuilder(SchemaIngestConfiguration.class, SchemaLoaderConfiguration.class).child(CrudApplication.class).properties(props)).run(args);
+ String deobfuscatedKeyStorePassword = Password.deobfuscate(keyStorePassword);
+ props.put("server.ssl.key-store-password", deobfuscatedKeyStorePassword);
+ props.put("schema.service.ssl.key-store-password", deobfuscatedKeyStorePassword);
+ props.put("schema.service.ssl.trust-store-password", deobfuscatedKeyStorePassword);
+ new CrudApplication()
+ .configure(new SpringApplicationBuilder(CrudApplication.class).properties(props))
+ .run(args);
}
/**
public static final ApiInfo DEFAULT_API_INFO = new ApiInfo("AAI NCSO Adapter Service", "AAI NCSO Adapter Service.",
"1.0", "urn:tos", DEFAULT_CONTACT, "Apache 2.0", "API license URL", Collections.emptyList());
-
-
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(DEFAULT_API_INFO).select().paths(PathSelectors.any())
.apis(RequestHandlerSelectors.basePackage("org.onap.crud")).build();
import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.Translator;
+import org.onap.schema.EdgePropsConfiguration;
+import org.onap.schema.EdgeRulesLoader;
+import org.onap.schema.OxmModelLoader;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
+@ComponentScan(basePackages = {"org.onap.aai.config", "org.onap.aai.setup"})
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
+@PropertySource(value = "file:${edgeprops.ingest.file}", ignoreResourceNotFound = true)
public class SchemaIngestConfiguration {
- @Bean
- public SchemaVersions schemaVersions() {
- return new SchemaVersions();
- }
+ @Autowired
+ private Translator translator;
@Bean
- public SchemaLocationsBean schemaLocationsBean() {
- return new SchemaLocationsBean();
+ public OxmModelLoader oxmModelLoader(NodeIngestor nodeIngestor) {
+ return new OxmModelLoader(translator, nodeIngestor );
}
@Bean
- public ConfigTranslator configTranslator() {
- return new AAIConfigTranslator(schemaLocationsBean(), schemaVersions());
+ public EdgeRulesLoader edgeRulesLoader(EdgeIngestor edgeIngestor) {
+ return new EdgeRulesLoader(translator, edgeIngestor, edgePropsConfiguration() );
}
@Bean
- public NodeIngestor nodeIngestor() {
- return new NodeIngestor(configTranslator());
+ public EdgePropsConfiguration edgePropsConfiguration() {
+ return new EdgePropsConfiguration();
}
@Bean
- public EdgeIngestor edgeIngestor() {
- return new EdgeIngestor(configTranslator(), schemaVersions());
+ @ConditionalOnExpression("'${schema.translator.list}'.contains('config')")
+ public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions) {
+ return new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
}
-
}
\ No newline at end of file
import org.apache.http.message.BasicNameValuePair;
import org.eclipse.jetty.util.security.Password;
import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.logging.LoggingContext;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.client.RestClient;
import org.onap.aai.restclient.enums.RestAuthenticationMode;
String url = baseTransactionUrl + "/" + id;
Map<String, List<String>> headers = new HashMap<>();
headers.put(HEADER_FROM_APP, Arrays.asList("Gizmo"));
- headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
+ headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
OperationResult getResult = client.get(url, headers, MediaType.APPLICATION_JSON_TYPE);
throw createErrorException(getResult, javax.ws.rs.core.Response.Status.NOT_FOUND, "No edge with id " + id + " found in graph");
}
}
-
+
@Override
public Edge getEdge(String id) throws CrudException {
String url = baseRelationshipUrl + "/" + id;
*/
package org.onap.crud.service;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.ws.rs.core.EntityTag;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response.Status;
+import net.dongliu.gson.GsonJava8TypeAdapterFactory;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.crud.dao.GraphDao;
import org.onap.crud.util.CrudServiceUtil;
import org.onap.schema.validation.OxmModelValidator;
import org.onap.schema.validation.RelationshipSchemaValidator;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.reflect.TypeToken;
-import net.dongliu.gson.GsonJava8TypeAdapterFactory;
public abstract class AbstractGraphDataService {
protected GraphDao daoForGet;
protected GraphDao dao;
public AbstractGraphDataService() throws CrudException {
- CrudServiceUtil.loadModels();
}
public ImmutablePair<EntityTag, String> getEdge(String version, String id, String type, Map<String, String> queryParams) throws CrudException {
*/
package org.onap.crud.util;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response.Status;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.crud.exception.CrudException;
import org.onap.crud.parser.EdgePayload;
import org.onap.crud.parser.util.EdgePayloadUtil;
import org.onap.schema.EdgeRulesLoader;
-import org.onap.schema.OxmModelLoader;
import org.onap.schema.RelationshipSchema;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonPrimitive;
-
public class CrudServiceUtil {
private static Gson gson = new Gson();
-
+ public static final java.lang.String LAST_MOD_SOURCE_OF_TRUTH = "last-mod-source-of-truth";
+ public static final java.lang.String SOURCE_OF_TRUTH = "source-of-truth";
+
@SuppressWarnings({"unchecked", "rawtypes"})
public static Object validateFieldType(String value, Class clazz) throws CrudException {
try {
}
}
- public static void loadModels() throws CrudException {
- // load the schemas
- try {
- OxmModelLoader.loadModels();
- EdgeRulesLoader.loadModels ();
- } catch (Exception e) {
- throw new CrudException(e);
- }
- }
-
/**
* This method will merge header property from app id in request payload if not already populated
* @param propertiesFromRequest
@SuppressWarnings("unchecked")
public static JsonElement mergeHeaderInFoToPayload(JsonElement propertiesFromRequest, HttpHeaders headers,
boolean isAdd) {
- String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
+ String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
Set<Map.Entry<String, JsonElement>> properties = new HashSet<Map.Entry<String, JsonElement>>();
properties.addAll(propertiesFromRequest.getAsJsonObject().entrySet());
-
+
Set<String> propertyKeys = new HashSet<String>();
for(Map.Entry<String, JsonElement> property : properties) {
propertyKeys.add(property.getKey());
}
-
- if(!propertyKeys.contains(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH)) {
- properties.add(new AbstractMap.SimpleEntry<String, JsonElement>(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH,
+
+ if(!propertyKeys.contains(LAST_MOD_SOURCE_OF_TRUTH)) {
+ properties.add(new AbstractMap.SimpleEntry<String, JsonElement>(LAST_MOD_SOURCE_OF_TRUTH,
(new JsonPrimitive(sourceOfTruth))));
}
-
- if(isAdd && !propertyKeys.contains(AAIProperties.SOURCE_OF_TRUTH)) {
- properties.add(new AbstractMap.SimpleEntry<String, JsonElement>(AAIProperties.SOURCE_OF_TRUTH,
+
+ if(isAdd && !propertyKeys.contains(SOURCE_OF_TRUTH)) {
+ properties.add(new AbstractMap.SimpleEntry<String, JsonElement>(SOURCE_OF_TRUTH,
(new JsonPrimitive(sourceOfTruth))));
}
public static String determineEdgeType(EdgePayload payload, String version) throws CrudException {
RelationshipSchema schema = EdgeRulesLoader.getSchemaForVersion(version);
-
+
if (payload.getSource() == null || payload.getTarget() == null) {
throw new CrudException("Source/Target not specified", Status.BAD_REQUEST);
}
-
- Set<String> edgeTypes = schema.getValidRelationTypes(EdgePayloadUtil.getVertexNodeType(payload.getSource()),
+
+ Set<String> edgeTypes = schema.getValidRelationTypes(EdgePayloadUtil.getVertexNodeType(payload.getSource()),
EdgePayloadUtil.getVertexNodeType(payload.getTarget()));
-
+
if (edgeTypes.size() == 0) {
throw new CrudException("No valid relationship types from " + payload.getSource() + " to " + payload.getTarget(), Status.BAD_REQUEST);
}
-
+
if (edgeTypes.size() > 1) {
throw new CrudException("Multiple possible relationship types from " + payload.getSource() + " to " + payload.getTarget(), Status.BAD_REQUEST);
}
-
+
return edgeTypes.iterator().next();
}
-
}
import java.util.regex.Pattern;\r
import java.util.stream.Collectors;\r
\r
+import javax.annotation.PostConstruct;\r
import javax.ws.rs.core.Response.Status;\r
\r
import org.apache.commons.io.IOUtils;\r
import org.onap.aai.edges.EdgeIngestor;\r
import org.onap.aai.edges.EdgeRule;\r
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;\r
-import org.onap.aai.setup.ConfigTranslator;\r
import org.onap.aai.setup.SchemaVersion;\r
+import org.onap.aai.setup.Translator;\r
import org.onap.crud.exception.CrudException;\r
import org.onap.crud.logging.CrudServiceMsgs;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import com.google.common.collect.Multimap;\r
\r
public class EdgeRulesLoader {\r
- \r
- private static ConfigTranslator configTranslator;\r
+\r
+ private static Translator translator;\r
private static EdgeIngestor edgeIngestor;\r
\r
private static EdgePropsConfiguration edgePropsConfiguration;\r
LoggerFactory.getInstance ().getLogger ( EdgeRulesLoader.class.getName () );\r
\r
private EdgeRulesLoader () { }\r
- \r
+\r
@Autowired\r
- public EdgeRulesLoader(ConfigTranslator configTranslator, EdgeIngestor edgeIngestor, EdgePropsConfiguration edgePropsConfiguration) {\r
- EdgeRulesLoader.configTranslator = configTranslator;\r
+ public EdgeRulesLoader(Translator translator, EdgeIngestor edgeIngestor, EdgePropsConfiguration edgePropsConfiguration) {\r
+ EdgeRulesLoader.translator = translator;\r
EdgeRulesLoader.edgeIngestor = edgeIngestor;\r
EdgeRulesLoader.edgePropsConfiguration = edgePropsConfiguration;\r
}\r
\r
+ @PostConstruct\r
+ public void init() throws CrudException {\r
+ EdgeRulesLoader.loadModels();\r
+ }\r
+ \r
/**\r
* Finds all DB Edge Rules and Edge Properties files for all OXM models.\r
*\r
\r
for (String version : OxmModelLoader.getLoadedOXMVersions()) {\r
try {\r
- SchemaVersion schemaVersion = configTranslator.getSchemaVersions().getVersions().stream()\r
+ SchemaVersion schemaVersion = translator.getSchemaVersions().getVersions().stream()\r
.filter(s -> s.toString().equalsIgnoreCase(version)).findAny().orElse(null);\r
loadModel(schemaVersion, edgeIngestor, propFiles);\r
} catch (IOException | EdgeRuleNotFoundException e) {\r
}\r
\r
try {\r
- SchemaVersion schemaVersion = configTranslator.getSchemaVersions().getVersions().stream()\r
+ SchemaVersion schemaVersion = translator.getSchemaVersions().getVersions().stream()\r
.filter(s -> s.toString().equalsIgnoreCase(v)).findAny().orElse(null);\r
\r
loadModel(schemaVersion, edgeIngestor, propFiles);\r
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.annotation.PostConstruct;
import javax.ws.rs.core.Response.Status;
import org.eclipse.persistence.dynamic.DynamicType;
import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.Translator;
import org.onap.crud.exception.CrudException;
import org.onap.crud.logging.CrudServiceMsgs;
import org.springframework.beans.factory.annotation.Autowired;
@Component
public class OxmModelLoader {
- private static ConfigTranslator configTranslator;
+ private static Translator translator;
private static NodeIngestor nodeIngestor;
-
+
private static Map<String, DynamicJAXBContext> versionContextMap = new ConcurrentHashMap<>();
private static Map<String, HashMap<String, DynamicType>> xmlElementLookup = new ConcurrentHashMap<>();
LoggerFactory.getInstance().getLogger(OxmModelLoader.class.getName());
private OxmModelLoader() { }
-
+
@Autowired
- public OxmModelLoader(ConfigTranslator configTranslator, NodeIngestor nodeIngestor) {
- OxmModelLoader.configTranslator = configTranslator;
+ public OxmModelLoader(Translator translator, NodeIngestor nodeIngestor) {
+ OxmModelLoader.translator = translator;
OxmModelLoader.nodeIngestor = nodeIngestor;
}
+ @PostConstruct
+ public void init() throws CrudException {
+ OxmModelLoader.loadModels();
+ }
+
/**
* Finds all OXM model files
*
logger.debug("Loading OXM Models");
}
- for (SchemaVersion oxmVersion : configTranslator.getSchemaVersions().getVersions()) {
+ for (SchemaVersion oxmVersion : translator.getSchemaVersions().getVersions()) {
DynamicJAXBContext jaxbContext = nodeIngestor.getContextForVersion(oxmVersion);
if (jaxbContext != null) {
loadModel(oxmVersion.toString(), jaxbContext);
public static void setVersionContextMap(Map<String, DynamicJAXBContext> versionContextMap) {
OxmModelLoader.versionContextMap = versionContextMap;
}
-
-
+
+
public static void loadXmlLookupMap(String version, DynamicJAXBContext jaxbContext ) {
@SuppressWarnings("rawtypes")
}
xmlElementLookup.put(version, types);
}
-
-
+
+
public static DynamicType getDynamicTypeForVersion(String version, String type) throws CrudException {
DynamicType dynamicType;
return dynamicType;
}
-
+
/**
* Retrieves the list of all Loaded OXM versions.
*
+spring.application.name=gizmo
+
server.port=9520
SERVICE_BEANS=dynamic/conf
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
-
+import java.util.Set;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.Translator;
import org.onap.schema.EdgePropsConfiguration;
import org.onap.schema.EdgeRulesLoader;
import org.onap.schema.OxmModelLoader;
Mockito.when(schemaLocationsBean.getNodesInclusionPattern()).thenReturn(Arrays.asList(".*oxm(.*).xml"));
Mockito.when(schemaLocationsBean.getEdgesInclusionPattern()).thenReturn(Arrays.asList("DbEdgeRules_.*.json"));
Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/multi-oxm/");
- Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/rules");
+ Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/rules/");
Mockito.when(edgePropsConfiguration.getEdgePropsDir()).thenReturn("src/test/resources/edgeProps/");
AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
- NodeIngestor nodeIngestor = new NodeIngestor(aaiConfigTranslator);
- EdgeIngestor edgeIngestor = new EdgeIngestor(aaiConfigTranslator, schemaVersions);
+ Set<Translator> translators = new HashSet<>();
+ translators.add(aaiConfigTranslator);
+ NodeIngestor nodeIngestor = new NodeIngestor(translators);
+ nodeIngestor.initialize();
+ EdgeIngestor edgeIngestor = new EdgeIngestor(translators);
+ edgeIngestor.initialize();
edgeRulesLoader = new EdgeRulesLoader(aaiConfigTranslator, edgeIngestor, edgePropsConfiguration);
oxmModelLoader = new OxmModelLoader(aaiConfigTranslator, nodeIngestor);
}
import org.onap.crud.event.envelope.GraphEventEnvelope;
import org.onap.crud.exception.CrudException;
import org.onap.crud.util.TestUtil;
+import org.onap.schema.EdgeRulesLoader;
import org.onap.schema.OxmModelLoader;
import com.google.gson.Gson;
import com.google.gson.JsonParser;
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
OxmModelLoader.loadModels();
+ EdgeRulesLoader.loadModels();
}
@Test
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
-import org.onap.aai.logging.LoggingContext;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.client.RestClient;
import org.onap.crud.dao.champ.ChampDao;
-import org.slf4j.MDC;
public class ChampDaoMockTest {
// @formatter:off
"\"properties\": {" +
"\"fqdn\": \"myhost.onap.com\"," +
"\"hostname\": \"myhost\" } }";
-
+
private final String champEdge = "{" +
"\"key\": \"test-uuid\"," +
"\"type\": \"edgeType\"," +
"\"target\": {" +
"\"key\": \"1d326bc7-b985-492b-9604-0d5d1f06f908\", \"type\": \"pserver\"}" +
" }";
-
- private final String edgePayload = "{" +
- "\"type\":\"tosca.relationships.HostedOn\"," +
- "\"properties\":{" +
- "\"prevent-delete\":\"NONE\"}," +
- "\"source\":{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"vserver\"," +
- "\"properties\":{}}," +
- "\"target\":{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "\"hostname\":\"myhost\"," +
+
+ private final String edgePayload = "{" +
+ "\"type\":\"tosca.relationships.HostedOn\"," +
+ "\"properties\":{" +
+ "\"prevent-delete\":\"NONE\"}," +
+ "\"source\":{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"vserver\"," +
+ "\"properties\":{}}," +
+ "\"target\":{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "\"hostname\":\"myhost\"," +
"\"fqdn\":\"myhost.onap.com\"}}}";
- private final String edgePayloadForPut = "{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"tosca.relationships.HostedOn\"," +
- "\"properties\":{" +
- "\"prevent-delete\":\"NONE\"}," +
- "\"source\":{" +
- "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
- "\"type\":\"vserver\"," +
- "\"properties\":{}}," +
- "\"target\":{" +
- "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
- "\"type\":\"pserver\"," +
+ private final String edgePayloadForPut = "{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"tosca.relationships.HostedOn\"," +
+ "\"properties\":{" +
+ "\"prevent-delete\":\"NONE\"}," +
+ "\"source\":{" +
+ "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
+ "\"type\":\"vserver\"," +
+ "\"properties\":{}}," +
+ "\"target\":{" +
+ "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
+ "\"type\":\"pserver\"," +
"\"properties\":{}}}";
-
- private final String edgePayloadForPatch = "{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"tosca.relationships.HostedOn\"," +
- "\"properties\":{" +
- "\"prevent-delete\":\"NONE\"}," +
- "\"source\":{" +
- "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
- "\"type\":\"vserver\"}," +
- "\"target\":{" +
- "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
+
+ private final String edgePayloadForPatch = "{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"tosca.relationships.HostedOn\"," +
+ "\"properties\":{" +
+ "\"prevent-delete\":\"NONE\"}," +
+ "\"source\":{" +
+ "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
+ "\"type\":\"vserver\"}," +
+ "\"target\":{" +
+ "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
"\"type\":\"pserver\"}}";
-
- private final String edgePayloadForPost = "{" +
- "\"type\":\"tosca.relationships.HostedOn\"," +
- "\"properties\":{" +
- "\"SVC-INFRA\":\"OUT\"," +
- "\"prevent-delete\":\"IN\"," +
- "\"delete-other-v\":\"NONE\"," +
- "\"contains-other-v\":\"NONE\"" +
- "}," +
- "\"source\":{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"vserver\"," +
- "\"properties\":{" +
- "" +
- "}" +
- "}," +
- "\"target\":{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "\"hostname\":\"myhost\"," +
- "\"fqdn\":\"myhost.onap.com\"" +
- "}" +
- "}" +
+
+ private final String edgePayloadForPost = "{" +
+ "\"type\":\"tosca.relationships.HostedOn\"," +
+ "\"properties\":{" +
+ "\"SVC-INFRA\":\"OUT\"," +
+ "\"prevent-delete\":\"IN\"," +
+ "\"delete-other-v\":\"NONE\"," +
+ "\"contains-other-v\":\"NONE\"" +
+ "}," +
+ "\"source\":{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"vserver\"," +
+ "\"properties\":{" +
+ "" +
+ "}" +
+ "}," +
+ "\"target\":{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "\"hostname\":\"myhost\"," +
+ "\"fqdn\":\"myhost.onap.com\"" +
+ "}" +
+ "}" +
"}";
-
- private final String edgePayloadForPutNoProperties = "{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"tosca.relationships.HostedOn\"," +
- "\"properties\":{" +
- "\"SVC-INFRA\":\"OUT\"," +
- "\"prevent-delete\":\"IN\"," +
- "\"delete-other-v\":\"NONE\"," +
- "\"contains-other-v\":\"NONE\"" +
- "}," +
- "\"source\":{" +
- "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
- "\"type\":\"vserver\"," +
- "\"properties\":{" +
- "" +
- "}" +
- "}," +
- "\"target\":{" +
- "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "" +
- "}" +
- "}" +
+
+ private final String edgePayloadForPutNoProperties = "{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"tosca.relationships.HostedOn\"," +
+ "\"properties\":{" +
+ "\"SVC-INFRA\":\"OUT\"," +
+ "\"prevent-delete\":\"IN\"," +
+ "\"delete-other-v\":\"NONE\"," +
+ "\"contains-other-v\":\"NONE\"" +
+ "}," +
+ "\"source\":{" +
+ "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
+ "\"type\":\"vserver\"," +
+ "\"properties\":{" +
+ "" +
+ "}" +
+ "}," +
+ "\"target\":{" +
+ "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "" +
+ "}" +
+ "}" +
"}";
-
- private final String vertexPayload = "{" +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "\"hostname\":\"myhost\"," +
- "\"in-maint\":false," +
- "\"fqdn\":\"myhost.onap.com\"," +
- "\"last-mod-source-of-truth\":\"source-of-truth\"," +
- "\"source-of-truth\":\"source-of-truth\"," +
+
+ private final String vertexPayload = "{" +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "\"hostname\":\"myhost\"," +
+ "\"in-maint\":false," +
+ "\"fqdn\":\"myhost.onap.com\"," +
+ "\"last-mod-source-of-truth\":\"source-of-truth\"," +
+ "\"source-of-truth\":\"source-of-truth\"," +
"\"aai-node-type\":\"pserver\"}}";
-
- private final String vertexPayloadForVserver = "{" +
- "\"type\":\"vserver\"," +
- "\"properties\":{" +
- "\"in-maint\":false," +
- "\"vserver-name\":\"test-vserver\"," +
- "\"vserver-id\":\"VSER1\"," +
- "\"last-mod-source-of-truth\":\"source-of-truth\"," +
- "\"vserver-name2\":\"alt-test-vserver\"," +
- "\"source-of-truth\":\"source-of-truth\"," +
- "\"vserver-selflink\":\"http://1.2.3.4/moreInfo\"," +
- "\"is-closed-loop-disabled\":false," +
+
+ private final String vertexPayloadForVserver = "{" +
+ "\"type\":\"vserver\"," +
+ "\"properties\":{" +
+ "\"in-maint\":false," +
+ "\"vserver-name\":\"test-vserver\"," +
+ "\"vserver-id\":\"VSER1\"," +
+ "\"last-mod-source-of-truth\":\"source-of-truth\"," +
+ "\"vserver-name2\":\"alt-test-vserver\"," +
+ "\"source-of-truth\":\"source-of-truth\"," +
+ "\"vserver-selflink\":\"http://1.2.3.4/moreInfo\"," +
+ "\"is-closed-loop-disabled\":false," +
"\"aai-node-type\":\"vserver\"}}";
-
- private final String vertexPayloadForPserver = "{" +
- "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "\"ptnii-equip-name\":\"e-name\"," +
- "\"hostname\":\"steve-host2\"," +
- "\"equip-type\":\"server\"," +
- "\"equip-vendor\":\"HP\"," +
- "\"equip-model\":\"DL380p-nd\"," +
- "\"in-maint\":false," +
- "\"fqdn\":\"myhost.onap.net\"," +
- "\"purpose\":\"my-purpose\"," +
- "\"ipv4-oam-address\":\"1.2.3.4\"," +
- "\"last-mod-source-of-truth\":\"source-of-truth\"," +
+
+ private final String vertexPayloadForPserver = "{" +
+ "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "\"ptnii-equip-name\":\"e-name\"," +
+ "\"hostname\":\"steve-host2\"," +
+ "\"equip-type\":\"server\"," +
+ "\"equip-vendor\":\"HP\"," +
+ "\"equip-model\":\"DL380p-nd\"," +
+ "\"in-maint\":false," +
+ "\"fqdn\":\"myhost.onap.net\"," +
+ "\"purpose\":\"my-purpose\"," +
+ "\"ipv4-oam-address\":\"1.2.3.4\"," +
+ "\"last-mod-source-of-truth\":\"source-of-truth\"," +
"\"aai-node-type\":\"pserver\"}}";
-
- private final String vertexPayloadForPut = "{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "\"hostname\":\"myhost\"," +
- "\"in-maint\":false," +
- "\"fqdn\":\"myhost.onap.com\"," +
- "\"last-mod-source-of-truth\":\"source-of-truth\"," +
+
+ private final String vertexPayloadForPut = "{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "\"hostname\":\"myhost\"," +
+ "\"in-maint\":false," +
+ "\"fqdn\":\"myhost.onap.com\"," +
+ "\"last-mod-source-of-truth\":\"source-of-truth\"," +
"\"aai-node-type\":\"pserver\"}}";
-
- private final String vertexPayloadForPatch = "{" +
- "\"key\":\"test-uuid\"," +
- "\"type\":\"pserver\"," +
- "\"properties\":{" +
- "\"hostname\":\"myhost\"," +
- "\"fqdn\":\"myhost.onap.com\"," +
- "\"last-mod-source-of-truth\":\"source-of-truth\"," +
+
+ private final String vertexPayloadForPatch = "{" +
+ "\"key\":\"test-uuid\"," +
+ "\"type\":\"pserver\"," +
+ "\"properties\":{" +
+ "\"hostname\":\"myhost\"," +
+ "\"fqdn\":\"myhost.onap.com\"," +
+ "\"last-mod-source-of-truth\":\"source-of-truth\"," +
"\"aai-node-type\":\"pserver\"}}";
// @formatter:on
Map<String, List<String>> headers = new HashMap<>();
headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME));
- headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString())));
+ headers.put(HEADER_TRANS_ID, Arrays.asList(HEADER_TRANS_ID_VALUE));
when(restClientMock.get(url, headers, MediaType.APPLICATION_JSON_TYPE)).thenReturn(operationResult);
}
operationResult.setResultCode(200);
String baseUrl = BASE_OBJECT_URL + "/" + RELATIONSHIP_SUB_URL + "/" + id;
String url;
-
+
if (txId != null) {
url = baseUrl + txId;
}
import org.onap.schema.EdgeRulesLoader;\r
import org.onap.schema.validation.MultiplicityValidator.MultiplicityType;\r
\r
-public class MultiplicityValidatorTest {\r
+import org.junit.runner.RunWith;\r
+import org.mockito.junit.MockitoJUnitRunner;\r
+import org.onap.crud.OXMModelLoaderSetup;\r
+\r
+@RunWith(MockitoJUnitRunner.Silent.class)\r
+public class MultiplicityValidatorTest extends OXMModelLoaderSetup{\r
\r
private final String postEdgePayload = "{" + "\"type\": \"tosca.relationships.HostedOn\","\r
+ "\"source\": \"services/inventory/v12/vserver/50bdab41-ad1c-4d00-952c-a0aa5d827811\","\r