<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ </dependency>
<!-- Test dependencies -->
<dependency>
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class AaiResourcesObject {
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+}
import java.util.List;\r
import org.onap.aai.modelloader.config.ModelLoaderConfig;\r
import org.onap.aai.modelloader.restclient.AaiRestClient;\r
+import org.springframework.web.client.RestTemplate;\r
\r
public abstract class ArtifactHandler {\r
\r
import java.util.Map;\r
import java.util.Map.Entry;\r
import java.util.UUID;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
import javax.xml.parsers.DocumentBuilder;\r
import javax.xml.parsers.DocumentBuilderFactory;\r
import org.apache.commons.text.StringEscapeUtils;\r
import org.onap.aai.modelloader.config.ModelLoaderConfig;\r
import org.onap.aai.modelloader.entity.Artifact;\r
import org.onap.aai.modelloader.entity.ArtifactHandler;\r
+import org.onap.aai.modelloader.entity.vnf.VnfImages;\r
import org.onap.aai.modelloader.restclient.AaiRestClient;\r
import org.onap.aai.modelloader.service.ModelLoaderMsgs;\r
-import org.onap.aai.restclient.client.OperationResult;\r
+import org.springframework.http.HttpStatus;\r
+import org.springframework.http.MediaType;\r
+import org.springframework.http.ResponseEntity;\r
import org.springframework.stereotype.Component;\r
+import org.springframework.web.client.RestTemplate;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
import org.w3c.dom.Node;\r
String imageId = imageIdBuilder.toString();\r
int resultCode = getVnfImage(restClient, distributionId, imageId, dataItem);\r
\r
- if (resultCode == Response.Status.NOT_FOUND.getStatusCode()) {\r
+ if (resultCode == HttpStatus.NOT_FOUND.value()) {\r
// This vnf-image is missing, so add it\r
boolean success = putVnfImage(restClient, dataItem, distributionId);\r
if (success) {\r
} else {\r
throw new VnfImageException(imageId);\r
}\r
- } else if (resultCode == Response.Status.OK.getStatusCode()) {\r
+ } else if (resultCode == HttpStatus.OK.value()) {\r
logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, imageId + " already exists. Skipping ingestion.");\r
} else {\r
// if other than 404 or 200, something went wrong\r
for (Entry<String, String> entry : dataItem.entrySet()) {\r
b.addParameter(entry.getKey(), entry.getValue());\r
}\r
- OperationResult tryGet =\r
- restClient.getResource(b.build().toString(), distributionId, MediaType.APPLICATION_JSON_TYPE);\r
+ ResponseEntity<VnfImages> tryGet =\r
+ restClient.getResource(b.build().toString(), distributionId, MediaType.APPLICATION_JSON, VnfImages.class);\r
if (tryGet == null) {\r
throw new VnfImageException(imageId);\r
}\r
- return tryGet.getResultCode();\r
+ return tryGet.getStatusCodeValue();\r
} catch (URISyntaxException ex) {\r
throw new VnfImageException(ex);\r
}\r
String uuid = UUID.randomUUID().toString();\r
dataItem.put(ATTR_UUID, uuid);\r
\r
+ // TODO: Get rid of the dataItem map and replace it with the VnfImage object\r
String payload = new Gson().toJson(dataItem);\r
String putUrl = config.getAaiBaseUrl() + config.getAaiVnfImageUrl() + "/vnf-image/" + uuid;\r
- OperationResult putResp =\r
- restClient.putResource(putUrl, payload, distributionId, MediaType.APPLICATION_JSON_TYPE);\r
- return putResp != null && putResp.getResultCode() == Response.Status.CREATED.getStatusCode();\r
+ ResponseEntity<String> putResp =\r
+ restClient.putResource(putUrl, payload, distributionId, MediaType.APPLICATION_JSON, String.class);\r
+ return putResp != null && putResp.getStatusCode() == HttpStatus.CREATED;\r
}\r
\r
private List<Map<String, String>> unmarshallVnfcData(Artifact vnfcArtifact) {\r
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.ws.rs.core.MediaType;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.restclient.AaiRestClient;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
import org.onap.aai.modelloader.util.GizmoTranslator;
-import org.onap.aai.restclient.client.OperationResult;
import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
public abstract class AbstractModelArtifact extends Artifact implements IModelArtifact {
protected boolean pushToGizmo(AaiRestClient aaiClient, ModelLoaderConfig config, String distId) {
try {
String gizmoPayload = GizmoTranslator.translate(getPayload());
- OperationResult postResponse = aaiClient.postResource(config.getAaiBaseUrl().trim(), gizmoPayload, distId,
- MediaType.APPLICATION_JSON_TYPE);
+ // TODO: Use correct responseType here
+ ResponseEntity<String> postResponse = aaiClient.postResource(config.getAaiBaseUrl().trim(), gizmoPayload, distId,
+ MediaType.APPLICATION_JSON, String.class);
- if (postResponse.getResultCode() != HttpStatus.OK.value()) {
+ if (postResponse.getStatusCode() != HttpStatus.OK) {
return false;
}
} catch (IOException e) {
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import java.util.List;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ConstrainedElementSet {
+ @JsonProperty("constrained-element-set-uuid")
+ private String constrainedElementSetUuid;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("constraint-type")
+ private String constraintType;
+
+ @JsonProperty("check-type")
+ private String checkType;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("element-choice-sets")
+ private List<ElementChoiceSet> elementChoiceSets;
+}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import java.util.List;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ElementChoiceSet {
+ @JsonProperty("element-choice-set-uuid")
+ private String elementChoiceSetUuid;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("element-choice-set-name")
+ private String elementChoiceSetName;
+
+ @JsonProperty("cardinality")
+ private String cardinality;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("model-elements")
+ private List<ModelElement> modelElements;
+}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class Metadatum {
+ @JsonProperty("metaname")
+ private String metaName;
+
+ @JsonProperty("metaval")
+ private String metaVal;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Describes the model returned by aai-resources
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class Model {
+
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantId;
+
+ @JsonProperty("model-role")
+ private String modelRole;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("model-vers")
+ List<ModelVersion> modelVersions;
+}
*/
package org.onap.aai.modelloader.entity.model;
-import java.io.StringWriter;
import java.util.List;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.XMLConstants;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.entity.ArtifactType;
import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.onap.aai.restclient.client.OperationResult;
-import org.w3c.dom.Node;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.HttpClientErrorException;
public class ModelArtifact extends AbstractModelArtifact {
private String modelVerId;
private String modelInvariantId;
- private Node modelVer;
+ private String modelVer;
private boolean firstVersionOfModel = false;
public ModelArtifact() {
this.modelInvariantId = modelInvariantId;
}
- public Node getModelVer() {
+ public String getModelVer() {
return modelVer;
}
- public void setModelVer(Node modelVer) {
+ public void setModelVer(String modelVer) {
this.modelVer = modelVer;
}
* @return true if a request to GET this resource as XML media is successful (status OK)
*/
private boolean xmlResourceCanBeFetched(AaiRestClient aaiClient, String distId, String xmlResourceUrl) {
- OperationResult getResponse = getResourceModel(aaiClient, distId, xmlResourceUrl);
- return getResponse != null && getResponse.getResultCode() == Response.Status.OK.getStatusCode();
+ try {
+ ResponseEntity<Model> getResponse = getResourceModel(aaiClient, distId, xmlResourceUrl);
+ return getResponse.getStatusCode().equals(HttpStatus.OK);
+ } catch (HttpClientErrorException e) {
+ if(e.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
}
/**
* @param xmlResourceUrl
* @return OperationResult the result of the operation
*/
- private OperationResult getResourceModel(AaiRestClient aaiClient, String distId, String xmlResourceUrl) {
- return aaiClient.getResource(xmlResourceUrl, distId, MediaType.APPLICATION_XML_TYPE);
+ private ResponseEntity<Model> getResourceModel(AaiRestClient aaiClient, String distId, String xmlResourceUrl) {
+ return aaiClient.getResource(xmlResourceUrl, distId, MediaType.APPLICATION_XML, Model.class);
}
/**
* @return true if the resource PUT as XML media was successful (status OK)
*/
private boolean putXmlResource(AaiRestClient aaiClient, String distId, String resourceUrl, String payload) {
- OperationResult putResponse =
- aaiClient.putResource(resourceUrl, payload, distId, MediaType.APPLICATION_XML_TYPE);
- return putResponse != null && putResponse.getResultCode() == Response.Status.CREATED.getStatusCode();
+ ResponseEntity<String> putResponse =
+ aaiClient.putResource(resourceUrl, payload, distId, MediaType.APPLICATION_XML, String.class);
+ return putResponse != null && putResponse.getStatusCode() == HttpStatus.CREATED;
}
@Override
// See whether the model is already present
String resourceUrl = getModelUrl(config);
- OperationResult result = getResourceModel(aaiClient, distId, resourceUrl);
+ // ResponseEntity<Model> result;
+ boolean modelExists = checkIfModelExists(aaiClient, distId, resourceUrl);
- if (result != null) {
- if (result.getResultCode() == Response.Status.OK.getStatusCode()) {
- success = updateExistingModel(aaiClient, config, distId, completedArtifacts);
- } else if (result.getResultCode() == Response.Status.NOT_FOUND.getStatusCode()) {
- success = createNewModel(aaiClient, distId, completedArtifacts, resourceUrl);
- } else {
- logModelUpdateFailure(
- "Response code " + result.getResultCode() + " invalid for getting resource model");
- }
+ if(modelExists) {
+ success = updateExistingModel(aaiClient, config, distId, completedArtifacts);
} else {
- logModelUpdateFailure("Null response from RestClient");
+ success = createNewModel(aaiClient, distId, completedArtifacts, resourceUrl);
}
+ // if (result != null) {
+ // if (result.getStatusCode() == HttpStatus.OK) {
+ // success = updateExistingModel(aaiClient, config, distId, completedArtifacts);
+ // } else if (result.getStatusCode() == HttpStatus.NOT_FOUND) {
+ // success = createNewModel(aaiClient, distId, completedArtifacts, resourceUrl);
+ // } else {
+ // logModelUpdateFailure(
+ // "Response code " + result.getStatusCodeValue() + " invalid for getting resource model");
+ // }
+ // } else {
+ // logModelUpdateFailure("Null response from RestClient");
+ // }
+
return success;
}
+ private boolean checkIfModelExists(AaiRestClient aaiClient, String distId, String resourceUrl) throws HttpClientErrorException {
+ try {
+ ResponseEntity<Model> response = getResourceModel(aaiClient, distId, resourceUrl);
+ return response.getStatusCode().equals(HttpStatus.OK);
+ } catch (HttpClientErrorException e) {
+ if(e.getStatusCode().equals(HttpStatus.NOT_FOUND)) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
+ }
+
private boolean createNewModel(AaiRestClient aaiClient, String distId, List<Artifact> completedArtifacts,
String resourceUrl) {
boolean success;
// Load the model version
boolean success = true;
- try {
- success = putXmlResource(aaiClient, distId, getModelVerUrl(config), nodeToString(getModelVer()));
- if (success) {
- completedArtifacts.add(this);
- logInfoMsg(getType() + " " + getUniqueIdentifier() + " successfully ingested.");
- } else {
- logModelUpdateFailure("Error pushing model");
- }
- } catch (TransformerException e) {
- logModelUpdateFailure(e.getMessage());
- success = false;
+ success = putXmlResource(aaiClient, distId, getModelVerUrl(config), getModelVer());
+ if (success) {
+ completedArtifacts.add(this);
+ logInfoMsg(getType() + " " + getUniqueIdentifier() + " successfully ingested.");
+ } else {
+ logModelUpdateFailure("Error pushing model");
}
return success;
return baseURL + subURL + instance;
}
-
- private String nodeToString(Node node) throws TransformerException {
- StringWriter sw = new StringWriter();
- TransformerFactory transFact = TransformerFactory.newInstance();
- transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
- transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
- Transformer t = transFact.newTransformer();
- t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- t.transform(new DOMSource(node), new StreamResult(sw));
- return sw.toString();
- }
}
*/
package org.onap.aai.modelloader.entity.model;
+import java.io.StringWriter;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collector;
import java.util.stream.IntStream;
import javax.xml.XMLConstants;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.modelloader.entity.Artifact;
parseRelationshipNode(node, model);
} else {
if (node.getNodeName().equalsIgnoreCase(MODEL_VER)) {
- ((ModelArtifact) model).setModelVer(node);
+ String modelVersion;
+ try {
+ modelVersion = nodeToString(node);
+ ((ModelArtifact) model).setModelVer(modelVersion);
+ } catch (TransformerException e) {
+ logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, "Failed to parse resource version for input: " + node.toString());
+ }
if (((ModelArtifact) model).getModelNamespace() != null
&& !((ModelArtifact) model).getModelNamespace().isEmpty()) {
Element e = (Element) node;
}
}
+ private String nodeToString(Node node) throws TransformerException {
+ StringWriter sw = new StringWriter();
+ TransformerFactory transFact = TransformerFactory.newInstance();
+ transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+ transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+ Transformer t = transFact.newTransformer();
+ t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ t.transform(new DOMSource(node), new StreamResult(sw));
+ return sw.toString();
+ }
+
/**
* {@inheritDoc}
*/
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import java.util.List;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ModelConstraint {
+ @JsonProperty("model-constraint-uuid")
+ private String modelConstraintUuid;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("constrained-element-set-uuid-to-replace")
+ private String constrainedElementSetUuidToReplace;
+
+ @JsonProperty("constrained-element-sets")
+ private List<ConstrainedElementSet> constrainedElementSets;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import java.util.List;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ModelElement {
+ @JsonProperty("model-element-uuid")
+ private String modelElementUuid;
+
+ @JsonProperty("new-data-del-flag")
+ private String newDataDelFlag;
+
+ @JsonProperty("cardinality")
+ private String cardinality;
+
+ @JsonProperty("linkage-points")
+ private String linkagePoints;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("model-elements")
+ private List<ModelElement> modelElements;
+
+ @JsonProperty("model-constraints")
+ private List<ModelConstraint> modelConstraints;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ModelVersion {
+
+ @JsonProperty("model-version-id")
+ private String modelVersionId;
+
+ @JsonProperty("model-name")
+ private String modelName;
+
+ @JsonProperty("model-version")
+ private String modelVersion;
+
+ @JsonProperty("distribution-status")
+ private String distributionStatus;
+
+ @JsonProperty("model-description")
+ private String modelDescription;
+
+ @JsonProperty("sdnc-model-name")
+ private String sdncModelName;
+
+ @JsonProperty("sdnc-model-version")
+ private String sdncModelVersion;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+
+ @JsonProperty("model-elements")
+ private List<ModelElement> modelElements;
+
+ @JsonProperty("metadata")
+ private List<Metadatum> metadata;
+
+}
package org.onap.aai.modelloader.entity.model;
import java.util.List;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.ArtifactType;
import org.onap.aai.modelloader.restclient.AaiRestClient;
import org.onap.aai.modelloader.entity.Artifact;
-import org.onap.aai.restclient.client.OperationResult;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
public class NamedQueryArtifact extends AbstractModelArtifact {
private boolean pushToResources(AaiRestClient aaiClient, ModelLoaderConfig config, String distId,
List<Artifact> completedArtifacts) {
- OperationResult getResponse =
- aaiClient.getResource(getNamedQueryUrl(config), distId, MediaType.APPLICATION_XML_TYPE);
- if (getResponse == null || getResponse.getResultCode() != Response.Status.OK.getStatusCode()) {
+ ResponseEntity<String> getResponse =
+ aaiClient.getResource(getNamedQueryUrl(config), distId, MediaType.APPLICATION_XML, String.class);
+ if (getResponse == null || getResponse.getStatusCode() != HttpStatus.OK) {
// Only attempt the PUT if the model doesn't already exist
- OperationResult putResponse = aaiClient.putResource(getNamedQueryUrl(config), getPayload(), distId,
- MediaType.APPLICATION_XML_TYPE);
- if (putResponse != null && putResponse.getResultCode() == Response.Status.CREATED.getStatusCode()) {
+ ResponseEntity<String> putResponse = aaiClient.putResource(getNamedQueryUrl(config), getPayload(), distId,
+ MediaType.APPLICATION_XML, String.class);
+ if (putResponse != null && putResponse.getStatusCode() == HttpStatus.CREATED) {
completedArtifacts.add(this);
logInfoMsg(getType().toString() + " " + getUniqueIdentifier() + " successfully ingested.");
} else {
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.vnf;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class VnfImage {
+ @JsonProperty("vnf-image-uuid")
+ private String vnfImageUuid;
+
+ private String application;
+
+ @JsonProperty("application-vendor")
+ private String applicationVendor;
+
+ @JsonProperty("application-version")
+ private String applicationVersion;
+
+ private String selfLink;
+
+ @JsonProperty("data-owner")
+ private String dataOwner;
+
+ @JsonProperty("data-source")
+ private String dataSource;
+
+ @JsonProperty("data-source-version")
+ private String dataSourceVersion;
+
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.entity.vnf;
+
+import java.util.List;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class VnfImages {
+ List<VnfImage> vnfImages;
+}
*/
package org.onap.aai.modelloader.restclient;
-import com.sun.jersey.core.util.MultivaluedMapImpl; // NOSONAR
-import java.io.IOException;
-import java.io.StringReader;
-import java.net.URI;
import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.IntStream;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
+import org.onap.aai.modelloader.entity.AaiResourcesObject;
import org.onap.aai.modelloader.service.ModelLoaderMsgs;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.restclient.enums.RestAuthenticationMode;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
+import org.springframework.web.client.RestTemplate;
/**
* Wrapper around the standard A&AI Rest Client interface. This currently uses Jersey client 1.x
@Component
public class AaiRestClient {
+ private static Logger logger = LoggerFactory.getInstance().getLogger(AaiRestClient.class.getName());
public static final String HEADER_TRANS_ID = "X-TransactionId";
public static final String HEADER_FROM_APP_ID = "X-FromAppId";
public static final String ML_APP_NAME = "ModelLoader";
private static final String RESOURCE_VERSION_PARAM = "resource-version";
+ private final ModelLoaderConfig config;
+ private final RestTemplate restTemplate;
- private static Logger logger = LoggerFactory.getInstance().getLogger(AaiRestClient.class.getName());
-
- private ModelLoaderConfig config = null;
-
- public AaiRestClient(ModelLoaderConfig config) {
+ public AaiRestClient(ModelLoaderConfig config, RestTemplate restTemplate) {
this.config = config;
+ this.restTemplate = restTemplate;
}
-
/**
* Send a GET request to the A&AI for a resource.
+ * @param <T>
*
* @param url
* @param transId
* @param mediaType
* @return
*/
- public OperationResult getResource(String url, String transId, MediaType mediaType) {
- return setupClient().get(url, buildHeaders(transId), mediaType);
+ public <T> ResponseEntity<T> getResource(String url, String transId, MediaType mediaType, Class<T> responseType) {
+ HttpHeaders headers = defaultHeaders(transId);
+ headers.setAccept(Collections.singletonList(mediaType));
+ HttpEntity<String> entity = new HttpEntity<>(headers);
+
+ return restTemplate.exchange(url, HttpMethod.GET, entity, responseType);
}
/**
* @param mediaType - the content type (XML or JSON)
* @return operation result
*/
- public OperationResult putResource(String url, String payload, String transId, MediaType mediaType) {
- logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload);
- return setupClient().put(url, payload, buildHeaders(transId), mediaType, mediaType);
+ public <T> ResponseEntity<T> putResource(String url, T payload, String transId, MediaType mediaType, Class<T> responseType) {
+ logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload.toString());
+ HttpHeaders headers = defaultHeaders(transId);
+ headers.setAccept(Collections.singletonList(mediaType));
+ headers.setContentType(mediaType);
+ HttpEntity<T> entity = new HttpEntity<>(payload, headers);
+
+ return restTemplate.exchange(url, HttpMethod.PUT, entity, responseType);
}
+ public <T> ResponseEntity<T> postResource(String url, T payload, String transId, MediaType mediaType, Class<T> responseType) {
+ logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload.toString());
+ HttpHeaders headers = defaultHeaders(transId);
+ headers.setAccept(Collections.singletonList(mediaType));
+ headers.setContentType(mediaType);
+ HttpEntity<T> entity = new HttpEntity<>(payload, headers);
- /**
- * Send a POST request to the A&AI.
- *
- * @param url - the url
- * @param transId - transaction ID
- * @param payload - the XML or JSON payload for the request
- * @param mimeType - the content type (XML or JSON)
- * @return ClientResponse
- */
- public OperationResult postResource(String url, String payload, String transId, MediaType mediaType) {
- logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload);
- return setupClient().post(url, payload, buildHeaders(transId), mediaType, mediaType);
+ return restTemplate.exchange(url, HttpMethod.POST, entity, responseType);
}
-
/**
* Send a DELETE request to the A&AI.
*
* @param transId - transaction ID
* @return ClientResponse
*/
- public OperationResult deleteResource(String url, String resourceVersion, String transId) {
- URI uri = UriBuilder.fromUri(url).queryParam(RESOURCE_VERSION_PARAM, resourceVersion).build();
- return setupClient().delete(uri.toString(), buildHeaders(transId), null);
+ public ResponseEntity<String> deleteResource(String url, String resourceVersion, String transId) {
+ HttpHeaders headers = defaultHeaders(transId);
+ String uri = url + "?" + RESOURCE_VERSION_PARAM + "=" + resourceVersion;
+ HttpEntity<String> entity = new HttpEntity<>(headers);
+ return restTemplate.exchange(uri, HttpMethod.DELETE, entity, String.class);
}
/**
* @param transId - transaction ID
* @return ClientResponse
*/
- public OperationResult getAndDeleteResource(String url, String transId) {
+ public ResponseEntity<?> getAndDeleteResource(String url, String transId) {
+ ResponseEntity<AaiResourcesObject> response = getResource(url, transId, MediaType.APPLICATION_XML, AaiResourcesObject.class);
// First, GET the model
- OperationResult getResponse = getResource(url, transId, MediaType.APPLICATION_XML_TYPE);
- if (getResponse == null || getResponse.getResultCode() != Response.Status.OK.getStatusCode()) {
- return getResponse;
+ if (response == null || response.getStatusCode() != HttpStatus.OK) {
+ return response;
}
- // Delete the model using the resource version in the response
- String resVersion = null;
- try {
- resVersion = getResourceVersion(getResponse);
- } catch (Exception e) {
- logger.error(ModelLoaderMsgs.AAI_REST_REQUEST_ERROR, "GET", url, e.getLocalizedMessage());
- return null;
- }
-
- return deleteResource(url, resVersion, transId);
+ return deleteResource(url, response.getBody().getResourceVersion(), transId);
}
- public boolean useBasicAuth() {
+ private boolean useBasicAuth() {
return config.getAaiAuthenticationUser() != null && config.getAaiAuthenticationPassword() != null;
}
- private RestClient setupClient() {
- RestClient restClient = new RestClient();
- restClient.validateServerHostname(false)
- .validateServerCertChain(false)
- .connectTimeoutMs(config.getClientConnectTimeoutMs())
- .readTimeoutMs(config.getClientReadTimeoutMs());
-
- //Use certs only if SSL is enabled
- if (config.useHttpsWithAAI())
- {// @formatter:off
- restClient
- .clientCertFile(config.getAaiKeyStorePath())
- .clientCertPassword(config.getAaiKeyStorePassword());
- // @formatter:on
- }
-
- if (useBasicAuth()) {
- restClient.authenticationMode(RestAuthenticationMode.SSL_BASIC);
- restClient.basicAuthUsername(config.getAaiAuthenticationUser());
- restClient.basicAuthPassword(config.getAaiAuthenticationPassword());
- }
-
- return restClient;
- }
-
/**
* Create the HTTP headers required for an A&AI operation (GET/POST/PUT/DELETE)
*
* @param transId
* @return map of headers
*/
- private Map<String, List<String>> buildHeaders(String transId) {
- MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.put(HEADER_TRANS_ID, Collections.singletonList(transId));
- headers.put(HEADER_FROM_APP_ID, Collections.singletonList(ML_APP_NAME));
+ private HttpHeaders defaultHeaders(String transId) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(AaiRestClient.HEADER_TRANS_ID, transId);
+ headers.set(AaiRestClient.HEADER_FROM_APP_ID, AaiRestClient.ML_APP_NAME);
+ if (useBasicAuth()) {
+ headers.setBasicAuth(config.getAaiAuthenticationUser(), config.getAaiAuthenticationPassword());
+ }
return headers;
}
-
- private String getResourceVersion(OperationResult getResponse)
- throws ParserConfigurationException, SAXException, IOException {
- String respData = getResponse.getResult();
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputSource is = new InputSource(new StringReader(respData));
- Document doc = builder.parse(is);
-
- NodeList nodesList = doc.getDocumentElement().getChildNodes();
-
- // @formatter:off
- return IntStream.range(0, nodesList.getLength()).mapToObj(nodesList::item)
- .filter(childNode -> childNode.getNodeName().equals(RESOURCE_VERSION_PARAM))
- .findFirst()
- .map(Node::getTextContent)
- .orElse(null);
- // @formatter:on
- }
}
package org.onap.aai.modelloader.restclient;
+import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
import org.onap.aai.babel.service.data.BabelArtifact;
import org.onap.aai.babel.service.data.BabelRequest;
-import org.onap.aai.babel.service.data.BabelArtifact.ArtifactType;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
String resourceUrl = config.getBabelBaseUrl() + config.getBabelGenerateArtifactsUrl();
HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
headers.set(AaiRestClient.HEADER_TRANS_ID, transactionId);
headers.set(AaiRestClient.HEADER_FROM_APP_ID, AaiRestClient.ML_APP_NAME);
HttpEntity<BabelRequest> entity = new HttpEntity<>(babelRequest, headers);
import java.util.ArrayList;
import java.util.List;
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifactHandler;
import org.onap.aai.modelloader.entity.model.ModelArtifactHandler;
@Component
public class ArtifactDeploymentManager {
- private final ModelLoaderConfig config;
private final ModelArtifactHandler modelArtifactHandler;
private final VnfCatalogArtifactHandler vnfCatalogArtifactHandler;
+ private final AaiRestClient aaiClient;
- public ArtifactDeploymentManager(ModelLoaderConfig config, ModelArtifactHandler modelArtifactHandler, VnfCatalogArtifactHandler vnfCatalogArtifactHandler) {
- this.config = config;
+ public ArtifactDeploymentManager(ModelArtifactHandler modelArtifactHandler, VnfCatalogArtifactHandler vnfCatalogArtifactHandler, AaiRestClient aaiClient) {
this.modelArtifactHandler = modelArtifactHandler;
this.vnfCatalogArtifactHandler = vnfCatalogArtifactHandler;
+ this.aaiClient = aaiClient;
}
/**
public boolean deploy(final INotificationData data, final List<Artifact> modelArtifacts,
final List<Artifact> catalogArtifacts) {
- AaiRestClient aaiClient = new AaiRestClient(config);
String distributionId = data.getDistributionID();
List<Artifact> completedArtifacts = new ArrayList<>();
package org.onap.aai.modelloader.config;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.util.List;
import java.util.Properties;
import org.eclipse.jetty.util.security.Password;
import org.junit.jupiter.api.Test;
-import org.onap.aai.modelloader.restclient.AaiRestClient;
import org.onap.sdc.utils.ArtifactTypeEnum;
/**
assertEquals(url, config.getBabelGenerateArtifactsUrl());
}
- @Test
- public void testMissingAuthenticationProperties() throws IOException {
- Properties props = new Properties();
- props.load(new FileInputStream("src/test/resources/model-loader-empty-auth-password.properties"));
-
- ModelLoaderConfig config = new ModelLoaderConfig(props, null);
- AaiRestClient aaiClient = new AaiRestClient(config);
-
- assertFalse(aaiClient.useBasicAuth(), "Empty AAI Password should result in no basic authentication");
-
- props.load(new FileInputStream("src/test/resources/model-loader-no-auth-password.properties"));
- config = new ModelLoaderConfig(props, null);
- aaiClient = new AaiRestClient(config);
-
- assertFalse(aaiClient.useBasicAuth(), "No AAI Password should result in no basic authentication");
- }
-
@Test
public void testGetUrls() {
Properties props = new Properties();
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.Properties;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.entity.ArtifactType;
import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.onap.aai.restclient.client.OperationResult;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
public class TestVnfCatalogArtifactHandler {
@Test
public void testUpdateVnfImages() throws Exception {
// GET operation
- OperationResult mockGetResp = mock(OperationResult.class);
+ ResponseEntity mockGetResp = mock(ResponseEntity.class);
// @formatter:off
- when(mockGetResp.getResultCode())
- .thenReturn(Response.Status.OK.getStatusCode())
- .thenReturn(Response.Status.NOT_FOUND.getStatusCode())
- .thenReturn(Response.Status.NOT_FOUND.getStatusCode())
- .thenReturn(Response.Status.OK.getStatusCode());
+ when(mockGetResp.getStatusCodeValue())
+ .thenReturn(HttpStatus.OK.value())
+ .thenReturn(HttpStatus.NOT_FOUND.value())
+ .thenReturn(HttpStatus.NOT_FOUND.value())
+ .thenReturn(HttpStatus.OK.value());
// @formatter:on
- when(mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), Mockito.any(MediaType.class)))
+ when(mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), Mockito.any(MediaType.class), Mockito.any()))
.thenReturn(mockGetResp);
mockPutOperations();
// Example VNF Catalog XML
VnfCatalogArtifactHandler handler = new VnfCatalogArtifactHandler(createConfig());
- assertThat(handler.pushArtifacts(createVnfCatalogArtifact(), "test", new ArrayList<Artifact>(), mockRestClient),
- is(true));
+ assertTrue(handler.pushArtifacts(createVnfCatalogArtifact(), "test", new ArrayList<Artifact>(), mockRestClient));
assertPutOperationsSucceeded();
}
@Test
public void testUpdateVnfImagesFromXml() throws Exception {
// GET operation
- OperationResult mockGetResp = mock(OperationResult.class);
+ ResponseEntity mockGetResp = mock(ResponseEntity.class);
// @formatter:off
- when(mockGetResp.getResultCode())
- .thenReturn(Response.Status.OK.getStatusCode())
- .thenReturn(Response.Status.NOT_FOUND.getStatusCode())
- .thenReturn(Response.Status.NOT_FOUND.getStatusCode())
- .thenReturn(Response.Status.OK.getStatusCode());
+ when(mockGetResp.getStatusCodeValue())
+ .thenReturn(HttpStatus.OK.value())
+ .thenReturn(HttpStatus.NOT_FOUND.value())
+ .thenReturn(HttpStatus.NOT_FOUND.value())
+ .thenReturn(HttpStatus.OK.value());
// @formatter:on
- when(mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), Mockito.any(MediaType.class)))
+ when(mockRestClient.getResource(Mockito.anyString(), Mockito.anyString(), Mockito.any(MediaType.class), Mockito.any()))
.thenReturn(mockGetResp);
mockPutOperations();
// Only two of the VNF images should be pushed
ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
AaiRestClient client = Mockito.verify(mockRestClient, Mockito.times(2));
- client.putResource(Mockito.anyString(), argument.capture(), Mockito.anyString(), Mockito.any(MediaType.class));
+ client.putResource(Mockito.anyString(), argument.capture(), Mockito.anyString(), Mockito.any(MediaType.class), Mockito.any());
assertThat(argument.getAllValues().size(), is(2));
assertThat(argument.getAllValues().get(0), containsString("5.2.5"));
assertThat(argument.getAllValues().get(0), containsString("VM00"));
* Always return CREATED (success) for a PUT operation.
*/
private void mockPutOperations() {
- OperationResult mockPutResp = mock(OperationResult.class);
- when(mockPutResp.getResultCode()).thenReturn(Response.Status.CREATED.getStatusCode());
+ ResponseEntity mockPutResp = mock(ResponseEntity.class);
+ when(mockPutResp.getStatusCode()).thenReturn(HttpStatus.CREATED);
when(mockRestClient.putResource(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
- Mockito.any(MediaType.class))).thenReturn(mockPutResp);
+ Mockito.any(MediaType.class), Mockito.any())).thenReturn(mockPutResp);
}
private void assertPutOperationsSucceeded() {
ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
AaiRestClient mockedClient = Mockito.verify(mockRestClient, Mockito.times(2));
mockedClient.putResource(Mockito.anyString(), argument.capture(), Mockito.anyString(),
- Mockito.any(MediaType.class));
+ Mockito.any(MediaType.class), Mockito.any());
assertThat(argument.getAllValues().get(0), containsString("3.16.9"));
assertThat(argument.getAllValues().get(0), containsString("VM00"));
assertThat(argument.getAllValues().get(1), containsString("3.16.1"));
import java.util.Collections;
import java.util.List;
-import javax.ws.rs.core.Response;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.onap.aai.restclient.client.OperationResult;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
/**
* Test the Model Artifact Handler using Mocks
assertTrue(true);
}
- @Test
- public void testSingleItemList() {
- when(config.getAaiBaseUrl()).thenReturn("");
- when(config.getAaiModelUrl(any())).thenReturn("");
-
- ModelArtifactHandler handler = new ModelArtifactHandler(config);
- List<Artifact> artifacts = Collections.singletonList(new ModelArtifact());
- handler.pushArtifacts(artifacts, "", Collections.emptyList(), aaiClient);
- handler.rollback(Collections.emptyList(), "", aaiClient);
- assertThat(artifacts, hasSize(1));
- }
-
@Test
public void testPushExistingModelsWithRollback() {
when(config.getAaiBaseUrl()).thenReturn("");
when(config.getAaiModelUrl(any())).thenReturn("");
- OperationResult operationResult = mock(OperationResult.class);
- when(aaiClient.getResource(any(), any(), any())).thenReturn(operationResult);
- when(operationResult.getResultCode()).thenReturn(Response.Status.OK.getStatusCode());
+ ResponseEntity operationResult = mock(ResponseEntity.class);
+ when(aaiClient.getResource(any(), any(), any(), any())).thenReturn(operationResult);
+ when(operationResult.getStatusCode()).thenReturn(HttpStatus.OK);
List<Artifact> artifacts = new ArrayList<>();
Artifact artifact = new ModelArtifact();
when(config.getAaiModelUrl(any())).thenReturn("");
when(config.getAaiNamedQueryUrl(any())).thenReturn("");
- OperationResult getResult = mock(OperationResult.class);
- when(aaiClient.getResource(any(), any(), any())).thenReturn(getResult);
- when(getResult.getResultCode()).thenReturn(Response.Status.NOT_FOUND.getStatusCode());
+ ResponseEntity getResult = mock(ResponseEntity.class);
+ when(aaiClient.getResource(any(), any(), any(), any())).thenReturn(getResult);
+ when(getResult.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND);
- OperationResult putResult = mock(OperationResult.class);
- when(aaiClient.putResource(any(), any(), any(), any())).thenReturn(putResult);
- when(putResult.getResultCode()).thenReturn(Response.Status.CREATED.getStatusCode());
+ ResponseEntity putResult = mock(ResponseEntity.class);
+ when(aaiClient.putResource(any(), any(), any(), any(), any())).thenReturn(putResult);
+ when(putResult.getStatusCode()).thenReturn(HttpStatus.CREATED);
List<Artifact> artifacts = new ArrayList<>();
artifacts.add(new ModelArtifact());
when(config.getAaiModelUrl(any())).thenReturn("");
when(config.getAaiNamedQueryUrl(any())).thenReturn("");
- OperationResult getResult = mock(OperationResult.class);
- when(aaiClient.getResource(any(), any(), any())).thenReturn(getResult);
- when(getResult.getResultCode()).thenReturn(Response.Status.NOT_FOUND.getStatusCode());
+ ResponseEntity getResult = mock(ResponseEntity.class);
+ when(aaiClient.getResource(any(), any(), any(), any())).thenReturn(getResult);
+ when(getResult.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND);
- OperationResult putResult = mock(OperationResult.class);
- when(aaiClient.putResource(any(), any(), any(), any())).thenReturn(putResult);
- when(putResult.getResultCode()).thenReturn(Response.Status.BAD_REQUEST.getStatusCode());
+ ResponseEntity putResult = mock(ResponseEntity.class);
+ when(aaiClient.putResource(any(), any(), any(), any(), any())).thenReturn(putResult);
+ when(putResult.getStatusCode()).thenReturn(HttpStatus.BAD_REQUEST);
checkRollback(Collections.singletonList(new ModelArtifact()));
}
when(config.getAaiBaseUrl()).thenReturn("");
when(config.getAaiModelUrl(any())).thenReturn("");
- OperationResult operationResult = mock(OperationResult.class);
- when(aaiClient.getResource(any(), any(), any())).thenReturn(operationResult);
- when(operationResult.getResultCode()).thenReturn(Response.Status.BAD_REQUEST.getStatusCode());
-
- checkRollback(Collections.singletonList(new ModelArtifact()));
- }
-
- @Test
- public void testNullResourceModelResult() {
- when(config.getAaiBaseUrl()).thenReturn("");
- when(config.getAaiModelUrl(any())).thenReturn("");
- when(aaiClient.getResource(any(), any(), any())).thenReturn(null);
+ ResponseEntity operationResult = mock(ResponseEntity.class);
+ when(aaiClient.getResource(any(), any(), any(), any())).thenReturn(operationResult);
+ when(operationResult.getStatusCode()).thenReturn(HttpStatus.BAD_REQUEST);
checkRollback(Collections.singletonList(new ModelArtifact()));
}
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.entity.ContentType;
import org.junit.jupiter.api.Test;
import org.onap.aai.modelloader.DistributionClientTestConfiguration;
import org.onap.aai.modelloader.entity.Artifact;
notificationData.setServiceVersion("2.0");
stubFor(get(urlEqualTo("/sdc/v1/catalog/services/DemovlbCds/1.0/artifacts/service-TestSvc-csar.csar"))
- .withHeader("Accept", equalTo(ContentType.APPLICATION_OCTET_STREAM.toString()))
+ .withHeader("Accept", equalTo(MediaType.APPLICATION_OCTET_STREAM_VALUE))
.withHeader("X-ECOMP-RequestID", matching(".+"))
.withHeader("X-ECOMP-InstanceID", equalTo("aai-ml-id-test"))
.willReturn(aResponse()
- .withHeader("Content-Type", MediaType.APPLICATION_OCTET_STREAM.toString())
+ .withHeader("Content-Type", MediaType.APPLICATION_OCTET_STREAM_VALUE)
.withBodyFile("service-TestSvc-csar.csar")));
stubFor(
.withRequestBody(matchingJsonPath("$.csar", matching(".*")))
.willReturn(
aResponse()
- .withHeader("Content-Type", "application/json")
+ .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE)
.withBodyFile("service-TestSvc-csar-babel-response.json")));
ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
import org.onap.aai.modelloader.entity.model.ModelArtifact;
import org.onap.aai.modelloader.entity.model.ModelArtifactHandler;
import org.onap.aai.modelloader.restclient.AaiRestClient;
-import org.onap.aai.restclient.client.OperationResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.http.HttpStatus;
-import org.w3c.dom.Node;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.client.WireMock;
WireMock.stubFor(
WireMock.put(urlEqualTo("/aai/v28/service-design-and-creation/models/model/modelInvariantId"))
- .withHeader("Content-Type", equalTo("application/xml"))
+ .withHeader("Accept", equalTo(MediaType.APPLICATION_XML_VALUE))
+ .withHeader("Content-Type", equalTo(MediaType.APPLICATION_XML_VALUE))
.withHeader("X-TransactionId", equalTo("someId"))
.withHeader("X-FromAppId", equalTo("ModelLoader"))
.willReturn(
ModelArtifact modelArtifact = new ModelArtifact();
modelArtifact.setModelInvariantId("modelInvariantId");
+ modelArtifact.setPayload("");
List<Artifact> artifacts = List.of(modelArtifact);
List<Artifact> completedArtifacts = new ArrayList<>();
WireMock.stubFor(
WireMock.put(urlEqualTo(
"/aai/v28/service-design-and-creation/models/model/modelInvariantId/model-vers/model-ver/modelVersionId"))
- .withHeader("Content-Type", equalTo("application/xml"))
+ .withHeader("Accept", equalTo(MediaType.APPLICATION_XML_VALUE))
+ .withHeader("Content-Type", equalTo(MediaType.APPLICATION_XML_VALUE))
.withHeader("X-TransactionId", equalTo("distributionId"))
.withHeader("X-FromAppId", equalTo("ModelLoader"))
.willReturn(
ModelArtifact modelArtifact = new ModelArtifact();
modelArtifact.setModelInvariantId("modelInvariantId");
modelArtifact.setModelVerId("modelVersionId");
- Node node = Mockito.mock(Node.class);
- modelArtifact.setModelVer(node);
+ modelArtifact.setPayload("");
+ modelArtifact.setModelVer("2.0");
List<Artifact> artifacts = List.of(modelArtifact);
List<Artifact> completedArtifacts = new ArrayList<>();
@Test
public void thatModelCanBeRolledBack() {
stubFor(WireMock.get(urlEqualTo("/aai/v28/service-design-and-creation/models/model/3a40ab73-6694-4e75-bb6d-9a4a86ce35b3"))
+ .withHeader("Accept", equalTo(MediaType.APPLICATION_XML_VALUE))
.withHeader("X-FromAppId", equalTo("ModelLoader"))
.withHeader("X-TransactionId", equalTo("distributionId"))
.willReturn(aResponse()
+ .withHeader("Content-Type", MediaType.APPLICATION_XML_VALUE)
.withBodyFile("modelResponse.xml")));
stubFor(WireMock.delete(urlEqualTo("/aai/v28/service-design-and-creation/models/model/3a40ab73-6694-4e75-bb6d-9a4a86ce35b3?resource-version=1710523260974"))
ModelArtifact modelArtifact = new ModelArtifact();
modelArtifact.setModelInvariantId("3a40ab73-6694-4e75-bb6d-9a4a86ce35b3");
modelArtifact.setModelVerId("modelVersionId");
- Node node = Mockito.mock(Node.class);
- modelArtifact.setModelVer(node);
+ // modelArtifact.setModelVer("2.0");
+
List<Artifact> completedArtifacts = new ArrayList<>();
completedArtifacts.add(modelArtifact);
* @param modelArtifact
*/
private void mockModelCreation(ModelArtifact modelArtifact) {
- OperationResult createdResult = Mockito.mock(OperationResult.class);
- when(createdResult.getResultCode()).thenReturn(HttpStatus.CREATED.value());
- OperationResult notFoundResult = Mockito.mock(OperationResult.class);
- when(notFoundResult.getResultCode()).thenReturn(HttpStatus.NOT_FOUND.value());
+ ResponseEntity createdResult = Mockito.mock(ResponseEntity.class);
+ when(createdResult.getStatusCode()).thenReturn(HttpStatus.CREATED);
+ ResponseEntity notFoundResult = Mockito.mock(ResponseEntity.class);
+ when(notFoundResult.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND);
AaiRestClient aaiClient = Mockito.mock(AaiRestClient.class);
- when(aaiClient.putResource(any(), any(), any(), any())).thenReturn(createdResult);
- when(aaiClient.getResource(any(), any(), any())).thenReturn(notFoundResult);
+ when(aaiClient.putResource(any(), any(), any(), any(), any())).thenReturn(createdResult);
+ when(aaiClient.getResource(any(), any(), any(), any())).thenReturn(notFoundResult);
modelArtifact.push(aaiClient, config, null, new ArrayList<>());
}
@Test
public void thatModelVersionCanBeRolledBack() {
- // "http://localhost:10594/aai/v28/service-design-and-creation/models/model/modelInvariantId/model-vers/model-ver/modelVersionId"
+ WireMock.stubFor(
+ WireMock.get(urlEqualTo(
+ "/aai/v28/service-design-and-creation/models/model/modelInvariantId/model-vers/model-ver/modelVersionId"))
+ .withHeader("Accept", equalTo("application/xml"))
+ .withHeader("X-TransactionId", equalTo("distributionId"))
+ .withHeader("X-FromAppId", equalTo("ModelLoader"))
+ .willReturn(
+ WireMock.aResponse()
+ .withHeader("Content-Type", MediaType.APPLICATION_XML_VALUE)
+ .withBodyFile("modelVersion.xml")));
+
+ stubFor(WireMock.delete(urlEqualTo("/aai/v28/service-design-and-creation/models/model/modelInvariantId/model-vers/model-ver/modelVersionId?resource-version=1708937324692"))
+ .withHeader("X-FromAppId", equalTo("ModelLoader"))
+ .withHeader("X-TransactionId", equalTo("distributionId"))
+ .willReturn(aResponse().withStatus(HttpStatus.OK.value())));
ModelArtifact modelArtifact = new ModelArtifact();
modelArtifact.setModelInvariantId("modelInvariantId");
modelArtifact.setModelVerId("modelVersionId");
- Node node = Mockito.mock(Node.class);
- modelArtifact.setModelVer(node);
+
List<Artifact> completedArtifacts = new ArrayList<>();
completedArtifacts.add(modelArtifact);
modelArtifactHandler.rollback(completedArtifacts, "distributionId", restClient);
+ verify(
+ deleteRequestedFor(
+ urlEqualTo("/aai/v28/service-design-and-creation/models/model/modelInvariantId/model-vers/model-ver/modelVersionId?resource-version=1708937324692")));
}
}
\ No newline at end of file
import org.onap.aai.modelloader.entity.model.ModelArtifactHandler;
import org.onap.aai.modelloader.extraction.InvalidArchiveException;
import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
+import org.onap.aai.modelloader.restclient.AaiRestClient;
import org.onap.aai.modelloader.service.ArtifactDeploymentManager;
import org.onap.aai.modelloader.util.ArtifactTestUtils;
import org.onap.sdc.api.notification.INotificationData;
+import org.springframework.web.client.RestTemplate;
/**
* Tests {@link ArtifactDeploymentManager}.
configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE));
ModelLoaderConfig modelLoaderConfig = new ModelLoaderConfig(configProperties, null);
- manager = new ArtifactDeploymentManager(modelLoaderConfig, modelArtifactHandlerMock, vnfCatalogArtifactHandlerMock);
+ AaiRestClient aaiRestClient = new AaiRestClient(modelLoaderConfig, new RestTemplate());
+ manager = new ArtifactDeploymentManager(modelArtifactHandlerMock, vnfCatalogArtifactHandlerMock, aaiRestClient);
}
@AfterEach
import java.util.stream.IntStream;
import java.util.stream.Stream;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilderFactory;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.ArtifactType;
import org.onap.aai.modelloader.entity.model.ModelArtifact;
import org.onap.aai.modelloader.entity.model.ModelArtifactParser;
-import org.onap.aai.restclient.client.OperationResult;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
model.setPayload(readFile(MODEL_FILE));
model.setModelNamespace("http://org.openecomp.aai.inventory/v9");
- AaiRestClient aaiClient = new AaiRestClient(config);
+ AaiRestClient aaiClient = new AaiRestClient(config, new RestTemplate());
// GET model
- OperationResult opResult =
- aaiClient.getResource(getUrl(model, config), "example-trans-id-0", MediaType.APPLICATION_XML_TYPE);
- assertEquals(opResult.getResultCode(), Response.Status.NOT_FOUND.getStatusCode());
+ ResponseEntity opResult =
+ aaiClient.getResource(getUrl(model, config), "example-trans-id-0", MediaType.APPLICATION_XML, String.class);
+ assertEquals(opResult.getStatusCode(), HttpStatus.NOT_FOUND);
// PUT the model
opResult = aaiClient.putResource(getUrl(model, config), model.getPayload(), "example-trans-id-1",
- MediaType.APPLICATION_XML_TYPE);
- assertEquals(opResult.getResultCode(), Response.Status.CREATED.getStatusCode());
+ MediaType.APPLICATION_XML, String.class);
+ assertEquals(opResult.getStatusCode(), HttpStatus.CREATED);
// DELETE the model
opResult = aaiClient.getAndDeleteResource(getUrl(model, config), "example-trans-id-3");
- assertEquals(opResult.getResultCode(), Response.Status.NO_CONTENT.getStatusCode());
+ assertEquals(opResult.getStatusCode(), HttpStatus.NO_CONTENT);
} catch (Exception e) {
e.printStackTrace();
}
+++ /dev/null
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.modelloader.restclient;
-
-import static javax.servlet.http.HttpServletResponse.SC_OK;
-import static org.apache.commons.io.IOUtils.write;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Properties;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.MediaType;
-
-import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.handler.AbstractHandler;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.aai.modelloader.config.ModelLoaderConfig;
-
-/**
- * Local testing of the A&AI Service client.
- *
- */
-public class TestAaiServiceClient {
-
- private Server server;
- private AaiRestClient aaiClient;
-
- @BeforeEach
- public void startJetty() throws Exception {
- server = new Server(0);
- server.setHandler(getMockHandler());
- server.start();
-
- Properties props = new Properties();
- props.put("ml.aai.KEYSTORE_PASSWORD", "2244");
- props.put("ml.aai.RESTCLIENT_CONNECT_TIMEOUT", "3000");
- props.put("ml.aai.RESTCLIENT_READ_TIMEOUT", "3000");
- ModelLoaderConfig config = new ModelLoaderConfig(props, ".");
- aaiClient = new AaiRestClient(config);
- }
-
- @AfterEach
- public void stopJetty() throws Exception {
- server.stop();
- }
-
- @Test
- public void testBuildAaiRestClient() {
- Properties props = new Properties();
- ModelLoaderConfig config = new ModelLoaderConfig(props, ".");
- new AaiRestClient(config);
- assertTrue(true);
- }
-
- @Test
- public void testOperations() {
- String url = server.getURI().toString();
- String transId = "";
- MediaType mediaType = MediaType.APPLICATION_JSON_TYPE;
- aaiClient.getResource(url, "", mediaType);
- aaiClient.deleteResource(url, "", transId);
- aaiClient.getAndDeleteResource(url, transId);
- aaiClient.postResource(url, "", transId, mediaType);
- aaiClient.putResource(url, "", transId, mediaType);
- assertTrue(true);
- }
-
-
- /**
- * Creates an {@link AbstractHandler handler} returning an arbitrary String as a response.
- *
- * @return never <code>null</code>.
- */
- private Handler getMockHandler() {
- Handler handler = new AbstractHandler() {
- @Override
- public void handle(String target, Request request, HttpServletRequest servletRequest,
- HttpServletResponse response) throws IOException, ServletException {
- response.setStatus(SC_OK);
- response.setContentType("text/json;charset=utf-8");
- write("", response.getOutputStream(), Charset.defaultCharset());
- request.setHandled(true);
- }
- };
- return handler;
- }
-}
-
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<model-ver
+ xmlns="http://org.onap.aai.inventory/v28">
+ <model-version-id>fe578080-ce19-4604-8760-fc264fbb2565</model-version-id>
+ <model-name>group-assignment</model-name>
+ <model-version>1.0</model-version>
+ <resource-version>1708937324692</resource-version>
+</model-ver>
\ No newline at end of file