/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.models.tosca.utils;
+import jakarta.ws.rs.core.Response;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.NonNull;
assertExist(serviceTemplate, ToscaUtils::checkPoliciesExist);
}
+ /**
+ * Assert that node templates have been specified correctly.
+ *
+ * @param serviceTemplate the service template containing node templates to be checked
+ */
+ public static void assertNodeTemplatesExist(final JpaToscaServiceTemplate serviceTemplate) {
+ assertExist(serviceTemplate, ToscaUtils::checkNodeTemplateExist);
+ }
+
/**
* Check that data types have been specified correctly.
*
return doExist(serviceTemplate, ToscaUtils::checkPoliciesExist);
}
+ /**
+ * Check that tosca node templates have been specified correctly.
+ *
+ * @param serviceTemplate the service template containing node templates to be checked
+ */
+ public static boolean doNodeTemplatesExist(final JpaToscaServiceTemplate serviceTemplate) {
+
+ return doExist(serviceTemplate, ToscaUtils::checkNodeTemplateExist);
+ }
+
/**
* Assert that something have been specified correctly.
*
return null;
}
+ /**
+ * Check if node templates have been specified correctly.
+ */
+ public static String checkNodeTemplateExist(final JpaToscaServiceTemplate serviceTemplate) {
+ if (serviceTemplate.getTopologyTemplate().getNodeTemplates() == null) {
+ return "node templates not present on the service template";
+ }
+
+ if (serviceTemplate.getTopologyTemplate().getNodeTemplates().getConceptMap().isEmpty()) {
+ return "no parameters present on the node templates";
+ }
+ return null;
+ }
+
/**
* getLatestPolicyTypeVersion Find all the ancestors of an entity type.
*