host=gerrit.onap.org
port=29418
project=policy/api.git
-defaultbranch=master
+defaultbranch=java-17
<artifactId>api-main</artifactId>
<name>${project.artifactId}</name>
<description>The main module of Policy Api that handles startup, lifecycle management, and parameters.</description>
+
<dependencies>
<dependency>
<groupId>org.onap.policy.models</groupId>
<artifactId>spring-utils</artifactId>
<version>${policy.common.version}</version>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils-test</artifactId>
<version>${policy.common.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <!-- Exclude the default Jackson dependency -->
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-json</artifactId>
- </exclusion>
- </exclusions>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-ui</artifactId>
+ <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
+ <version>2.1.0</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
- <version>${version.io.micrometer}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>10.1.11</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
</dependencies>
<build>
<resources>
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
+ <version>3.0.46</version>
<executions>
<execution>
<id>code-gen</id>
<dateLibrary>java11</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
+ <jakarta>true</jakarta>
</configOptions>
</configuration>
</execution>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${version.springboot}</version>
<executions>
<execution>
<goals>
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.config;
-import javax.servlet.Filter;
+import jakarta.servlet.Filter;
import org.onap.policy.api.main.rest.aaf.AafApiFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
public Filter aafFilter() {
return new AafApiFilter();
}
-}
\ No newline at end of file
+}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
+@Getter
@Component
@ConfigurationProperties("policy-preload")
public class PolicyPreloadConfig {
- @Getter
@Setter
List<String> policyTypes;
- @Getter
@Setter
List<String> policies;
-}
\ No newline at end of file
+}
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
/**
*/
@Configuration
public class SecurityConfig {
+
/**
* Return the configuration of how access to this module's REST end points is secured.
*
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
- .httpBasic()
- .and()
- .authorizeHttpRequests().anyRequest().authenticated()
- .and()
- .csrf().disable();
+ .httpBasic(Customizer.withDefaults())
+ .authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated())
+ .csrf(AbstractHttpConfigurer::disable);
return http.build();
}
-}
\ No newline at end of file
+}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.config;
-import java.util.Arrays;
import java.util.List;
import org.onap.policy.api.main.config.converter.StringToEnumConverter;
import org.onap.policy.common.spring.utils.YamlHttpMessageConverter;
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
var yamlConverter = new YamlHttpMessageConverter();
- yamlConverter.setSupportedMediaTypes(Arrays.asList(MediaType.parseMediaType("application/yaml")));
+ yamlConverter.setSupportedMediaTypes(List.of(MediaType.parseMediaType("application/yaml")));
converters.add(yamlConverter);
}
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.exception;
+import java.io.Serial;
+
/**
* This exception will be called if an error occurs in policy api external service.
*/
public class PolicyApiException extends Exception {
+ @Serial
private static final long serialVersionUID = -8507246953751956974L;
/**
* Instantiates a new policy api exception with a message and a caused by exception.
*
* @param message the message
- * @param exp the exception that caused this exception to be thrown
+ * @param exp the exception that caused this exception to be thrown
*/
public PolicyApiException(final String message, final Exception exp) {
super(message, exp);
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.exception;
+import java.io.Serial;
import java.util.UUID;
import lombok.Getter;
import org.onap.policy.models.errors.concepts.ErrorResponse;
/**
* This runtime exception will be called if a runtime error occurs when using policy api.
*/
+@Getter
public class PolicyApiRuntimeException extends RuntimeException {
+ @Serial
private static final long serialVersionUID = -8507246953751956974L;
- @Getter
private final UUID requestId;
- @Getter
private final ErrorResponse errorResponse;
/**
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Bell Canada. All rights reserved.
+ * Copyright (C) 2022-2023 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.exception;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
* ================================================================================\r
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.\r
+ * Modifications Copyright (C) 2020-2023 Nordix Foundation.\r
* Modifications Copyright (C) 2020-2023 Bell Canada. All rights reserved.\r
* ================================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
\r
package org.onap.policy.api.main.rest;\r
\r
+import jakarta.ws.rs.core.Response.Status;\r
import java.util.List;\r
import java.util.UUID;\r
-import javax.ws.rs.core.Response.Status;\r
import lombok.RequiredArgsConstructor;\r
import org.onap.policy.api.main.exception.PolicyApiRuntimeException;\r
import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;\r
import org.onap.policy.models.base.PfModelRuntimeException;\r
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
import org.springframework.context.annotation.Profile;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
import org.springframework.http.ResponseEntity;\r
import org.springframework.web.bind.annotation.RestController;\r
\r
@Profile("default")\r
public class ApiRestController extends CommonRestController implements PolicyDesignApi {\r
\r
- private enum Target {\r
- POLICY,\r
- POLICY_TYPE,\r
- OTHER\r
- }\r
-\r
private final ToscaServiceTemplateService toscaServiceTemplateService;\r
private final HealthCheckProvider healthCheckProvider;\r
\r
* Retrieves all versions of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(\r
- String policyTypeId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);\r
return makeOkResponse(requestId, serviceTemplate);\r
* Retrieves specified version of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- * @param versionId the version of specified policy type\r
- *\r
+ * @param versionId the version of specified policy type\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(\r
- String policyTypeId,\r
- String versionId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String versionId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);\r
* Retrieves latest version of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(\r
- String policyTypeId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);\r
return makeOkResponse(requestId, serviceTemplate);\r
* Creates a new policy type.\r
*\r
* @param body the body of policy type following TOSCA definition\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> createPolicyType(\r
- ToscaServiceTemplate body,\r
- UUID requestId) {\r
+ ToscaServiceTemplate body,\r
+ UUID requestId) {\r
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));\r
}\r
* Deletes specified version of a particular policy type.\r
*\r
* @param policyTypeId the ID of specified policy type\r
- * @param versionId the version of specified policy type\r
- *\r
+ * @param versionId the version of specified policy type\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(\r
- String policyTypeId,\r
- String versionId,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String versionId,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);\r
/**\r
* Retrieves all versions of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getAllPolicies(\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);\r
/**\r
* Retrieves all versions of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(\r
- String policyId,\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);\r
/**\r
* Retrieves the specified version of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- * @param policyVersion the version of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
+ * @param policyVersion the version of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(\r
- String policyId,\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- String policyVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ String policyVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService\r
.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);\r
/**\r
* Retrieves the latest version of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(\r
- String policyId,\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);\r
/**\r
* Creates a new policy for a particular policy type and version.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param body the body of policy following TOSCA definition\r
- *\r
+ * @param body the body of policy following TOSCA definition\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> createPolicy(\r
- String policyTypeId,\r
- String policyTypeVersion,\r
- ToscaServiceTemplate body,\r
- UUID requestId) {\r
+ String policyTypeId,\r
+ String policyTypeVersion,\r
+ ToscaServiceTemplate body,\r
+ UUID requestId) {\r
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,\r
"/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));\r
/**\r
* Deletes the specified version of a particular policy.\r
*\r
- * @param policyTypeId the ID of specified policy type\r
+ * @param policyTypeId the ID of specified policy type\r
* @param policyTypeVersion the version of specified policy type\r
- * @param policyId the ID of specified policy\r
- * @param policyVersion the version of specified policy\r
- *\r
+ * @param policyId the ID of specified policy\r
+ * @param policyVersion the version of specified policy\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getPolicies(\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);\r
/**\r
* Retrieves the specified version of a particular policy.\r
*\r
- * @param policyId the Name of specified policy\r
+ * @param policyId the Name of specified policy\r
* @param policyVersion the version of specified policy\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(\r
- String policyId,\r
- String policyVersion,\r
- PolicyFetchMode mode,\r
- UUID requestId) {\r
+ String policyId,\r
+ String policyVersion,\r
+ PolicyFetchMode mode,\r
+ UUID requestId) {\r
try {\r
ToscaServiceTemplate serviceTemplate =\r
toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);\r
* Creates one or more new policies in one call.\r
*\r
* @param body the body of policy following TOSCA definition\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
/**\r
* Deletes the specified version of a particular policy.\r
*\r
- * @param policyId the ID of specified policy\r
+ * @param policyId the ID of specified policy\r
* @param policyVersion the version of specified policy\r
- *\r
* @return the Response object containing the results of the API operation\r
*/\r
@Override\r
* ================================================================================\r
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.\r
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.\r
- * Modifications Copyright (C) 2022 Nordix Foundation.\r
+ * Modifications Copyright (C) 2022-2023 Nordix Foundation.\r
* ================================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.policy.api.main.rest;\r
\r
+import java.util.Objects;\r
import java.util.UUID;\r
import org.onap.policy.api.main.exception.PolicyApiRuntimeException;\r
import org.onap.policy.common.utils.coder.Coder;\r
* @return the response builder, with version logging\r
*/\r
public static ResponseEntity.BodyBuilder addLoggingHeaders(ResponseEntity.BodyBuilder respBuilder, UUID requestId) {\r
- if (requestId == null) {\r
- // Generate a random uuid if client does not embed requestId in rest request\r
- return respBuilder.header(REQUEST_ID_NAME, UUID.randomUUID().toString());\r
- }\r
+ // Generate a random uuid if client does not embed requestId in rest request\r
+ return respBuilder.header(REQUEST_ID_NAME,\r
+ Objects.requireNonNullElseGet(requestId, UUID::randomUUID).toString());\r
\r
- return respBuilder.header(REQUEST_ID_NAME, requestId.toString());\r
}\r
\r
/**\r
package org.onap.policy.api.main.rest.stub;
+import jakarta.validation.Valid;
import java.util.UUID;
-import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.rest.CommonRestController;
import org.onap.policy.api.main.rest.PolicyFetchMode;
@Override
public ResponseEntity<ToscaServiceTemplate> createPolicies(
- @Valid ToscaServiceTemplate body, UUID requestID) {
+ @Valid ToscaServiceTemplate body, UUID requestID) {
return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
}
@Override
public ResponseEntity<ToscaServiceTemplate> createPolicyType(
- @Valid ToscaServiceTemplate body, UUID requestID) {
+ @Valid ToscaServiceTemplate body, UUID requestID) {
return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
}
@Override
public ResponseEntity<ToscaServiceTemplate> deleteSpecificPolicy(
- String policyId,
- String policyVersion,
- UUID requestID) {
+ String policyId,
+ String policyVersion,
+ UUID requestID) {
return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
}
package org.onap.policy.api.main.rest.stub;
+import jakarta.validation.Valid;
import java.util.List;
import java.util.UUID;
-import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.rest.CommonRestController;
import org.onap.policy.api.main.rest.genapi.ToscaNodeTemplateDesignApi;
package org.onap.policy.api.main.rest.stub;
import com.google.gson.Gson;
+import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
import java.util.List;
-import javax.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final var resource = new ClassPathResource(TOSCA_NODE_TEMPLATE_RESOURCE);
try (var inputStream = resource.getInputStream()) {
final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
- var targetObject = Arrays.asList(JSON_TRANSLATOR.fromJson(string, clazz));
+ var targetObject = List.of(JSON_TRANSLATOR.fromJson(string, clazz));
return new ResponseEntity<>(targetObject, HttpStatus.OK);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. 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.
package org.onap.policy.api.main.service;
+import jakarta.ws.rs.core.Response;
import java.util.Optional;
-import javax.ws.rs.core.Response;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.repository.NodeTemplateRepository;
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.service;
+import jakarta.ws.rs.core.Response;
import java.util.List;
import java.util.stream.Collectors;
-import javax.ws.rs.core.Response;
import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.repository.PdpGroupRepository;
import org.onap.policy.models.base.PfModelRuntimeException;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2022 Nordix Foundation.
+ * Modifications Copyright (C) 2022-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.service;
+import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-import javax.annotation.Nonnull;
-import javax.ws.rs.core.Response;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
// append the incoming fragment to the DB TOSCA service template
var dbServiceTemplateOpt = getDefaultJpaToscaServiceTemplateOpt();
JpaToscaServiceTemplate serviceTemplateToWrite;
- if (dbServiceTemplateOpt.isEmpty()) {
- serviceTemplateToWrite = incomingServiceTemplate;
- } else {
- serviceTemplateToWrite =
- ToscaServiceTemplateUtils.addFragment(dbServiceTemplateOpt.get(), incomingServiceTemplate);
- }
+ serviceTemplateToWrite = dbServiceTemplateOpt.map(
+ jpaToscaServiceTemplate -> ToscaServiceTemplateUtils.addFragment(jpaToscaServiceTemplate,
+ incomingServiceTemplate)).orElse(incomingServiceTemplate);
final var result = serviceTemplateToWrite.validate("service template");
if (!result.isValid()) {
// append the incoming fragment to the DB TOSCA service template
var dbServiceTemplateOpt = getDefaultJpaToscaServiceTemplateOpt();
JpaToscaServiceTemplate serviceTemplateToWrite;
- if (dbServiceTemplateOpt.isEmpty()) {
- serviceTemplateToWrite = incomingServiceTemplate;
- } else {
- serviceTemplateToWrite =
- ToscaServiceTemplateUtils.addFragment(dbServiceTemplateOpt.get(), incomingServiceTemplate);
- }
+ serviceTemplateToWrite = dbServiceTemplateOpt.map(
+ jpaToscaServiceTemplate -> ToscaServiceTemplateUtils.addFragment(jpaToscaServiceTemplate,
+ incomingServiceTemplate)).orElse(incomingServiceTemplate);
final var result = serviceTemplateToWrite.validate("Policies CRUD service template.");
if (!result.isValid()) {
* @return the TOSCA service template containing the node template that were deleted
* @throws PfModelException on errors deleting node templates
*/
- public ToscaServiceTemplate deleteToscaNodeTemplate(@NonNull final String name, @Nonnull final String version)
+ public ToscaServiceTemplate deleteToscaNodeTemplate(@NonNull final String name, @NonNull final String version)
throws PfModelException {
LOGGER.debug("->deleteToscaNodeTemplate: name={}, version={}", name, version);
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.api.main.startstop;
import com.google.common.collect.Sets;
+import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import javax.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.config.PolicyPreloadConfig;
import org.onap.policy.api.main.exception.PolicyApiException;
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2020 Nordix Foundation.
+ Copyright (C) 2019-2020, 2022-2023 Nordix Foundation.
Modifications Copyright (C) 2021 AT&T Intellectual Property.
- Modification Copyright 2022 Nordix Foundation.
Modifications Copyright (C) 2023 Bell Canada. All rights reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
<properties>
- <property name="javax.persistence.schema-generation.database.action" value="none" />
+ <property name="jakarta.persistence.schema-generation.database.action" value="none" />
<property name="eclipselink.ddl-generation" value="none" />
<property name="eclipselink.logging.level" value="WARNING" />
</properties>
openapi: 3.0.1
info:
title: Policy Framework Lifecycle API
- description: The Policy Fraemwork API allows the lifecycle of policy types and policyes to be managed
+ description: The Policy Framework API allows the lifecycle of policy types and policies to be managed
contact:
name: ONAP Support
url: https://lists.onap.org/g/onap-discuss
import static org.junit.Assert.assertEquals;
+import jakarta.ws.rs.core.Response;
import java.io.IOException;
-import javax.ws.rs.core.Response;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.api.main.PolicyApiApplication;
import org.onap.policy.api.main.rest.utils.CommonTestRestController;
import org.onap.policy.common.utils.security.SelfSignedKeyStore;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = PolicyApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles({ "test", "stub" })
+@ActiveProfiles({"test", "stub"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class ApiContractTest extends CommonTestRestController {
+class ApiContractTest extends CommonTestRestController {
protected static final String APP_JSON = "application/json";
protected static final String APP_YAML = "application/yaml";
private static final String TOSCA_NODE_TEMPLATE_RESOURCE =
- "nodetemplates/nodetemplates.metadatasets.input.tosca.json";
+ "nodetemplates/nodetemplates.metadatasets.input.tosca.json";
@LocalServerPort
private int apiPort;
private static SelfSignedKeyStore keystore;
-
- @BeforeClass
+ @BeforeAll
public static void setupParameters() throws IOException, InterruptedException {
keystore = new SelfSignedKeyStore();
}
}
@Test
- public void testStubPolicyDesign() throws Exception {
+ void testStubPolicyDesign() throws Exception {
checkStubJsonGet("policies");
checkStubJsonGet("policies/policyname/versions/1.0.2");
checkStubJsonGet("policytypes");
checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16");
checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/latest");
- checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/");
+ checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0");
checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies");
checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
+ "9c65fa1f-2833-4076-a64d-5b62e35cd09b");
checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
- + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/latest");
+ + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/latest");
checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
- + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
+ + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
checkStubJsonGet("healthcheck");
checkStubJsonPost("policies");
checkStubJsonDelete("policies/policyname/versions/1.0.2");
checkStubJsonDelete("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0");
checkStubJsonDelete("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
- + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
+ + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
}
@Test
- public void testStubNodeTemplateDesign() throws Exception {
+ void testStubNodeTemplateDesign() throws Exception {
checkStubJsonGet("nodetemplates");
checkStubJsonGet("nodetemplates/k8stemplate/versions/1.0.0");
}
@Test
- public void testErrors() throws Exception {
+ void testErrors() throws Exception {
var responseYaml = super.readResource("policies", APP_YAML, apiPort);
assertEquals(Response.Status.NOT_IMPLEMENTED.getStatusCode(), responseYaml.getStatus());
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.exception;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class TestPolicyApiException {
+class TestPolicyApiException {
@Test
- public void test() {
- assertEquals(3, new ExceptionsTester().test(PolicyApiException.class));
+ void test() {
+ Assertions.assertEquals(3, new ExceptionsTester().test(PolicyApiException.class));
}
}
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.exception;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class TestPolicyApiRuntimeException {
+class TestPolicyApiRuntimeException {
@Test
- public void test() {
- assertEquals(2, new ExceptionsTester().test(PolicyApiRuntimeException.class));
+ void test() {
+ Assertions.assertEquals(2, new ExceptionsTester().test(PolicyApiRuntimeException.class));
}
}
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022-2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022-2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2023 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.api.main.PolicyApiApplication;
import org.onap.policy.api.main.rest.utils.CommonTestRestController;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* Class to perform unit test of {@link ApiRestController}.
*
* @author Chenfei Gao (cgao@research.att.com)
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = PolicyApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles({ "test", "default" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class TestApiRestServer extends CommonTestRestController {
+class TestApiRestServer extends CommonTestRestController {
private static final String ALIVE = "alive";
private static final String SELF = NetworkUtil.getHostname();
* @throws IOException on I/O exceptions
* @throws InterruptedException if interrupted
*/
- @BeforeClass
- public static void setupParameters() throws IOException, InterruptedException {
+ @BeforeAll
+ static void setupParameters() throws IOException, InterruptedException {
keystore = new SelfSignedKeyStore();
}
}
@Test
- public void testSwagger() throws Exception {
+ void testSwagger() throws Exception {
super.testSwagger(apiPort);
}
@Test
- public void testCreatePolicyTypes() throws Exception {
+ void testCreatePolicyTypes() throws Exception {
for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
Response rawResponse = createResource(POLICYTYPES, resrcName, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
}
@Test
- public void testCreatePolicies() throws Exception {
+ void testCreatePolicies() throws Exception {
for (String resrcName : TOSCA_POLICY_RESOURCE_NAMES) {
Response rawResponse = createResource(POLICYTYPES_TCA_POLICIES, resrcName, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
}
@Test
- public void testSimpleCreatePolicies() throws Exception {
+ void testSimpleCreatePolicies() throws Exception {
for (String resrcName : TOSCA_POLICIES_RESOURCE_NAMES) {
Response rawResponse = createResource(POLICIES, resrcName, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
@SuppressWarnings("unchecked")
@Test
- public void testToscaCompliantOpDroolsPolicies() throws Exception {
+ void testToscaCompliantOpDroolsPolicies() throws Exception {
Response rawResponse = createResource(POLICYTYPES, TOSCA_POLICYTYPE_OP_RESOURCE, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
}
@Test
- public void testHealthCheckSuccessJson() throws Exception {
+ void testHealthCheckSuccessJson() throws Exception {
testHealthCheckSuccess(APP_JSON);
}
@Test
- public void testHealthCheckSuccessYaml() throws Exception {
+ void testHealthCheckSuccessYaml() throws Exception {
testHealthCheckSuccess(APP_YAML);
}
private void testHealthCheckSuccess(String mediaType) throws Exception {
final Invocation.Builder invocationBuilder = sendHttpsRequest(
- CONTEXT_PATH, HEALTHCHECK_ENDPOINT, mediaType, apiPort);
+ HEALTHCHECK_ENDPOINT, mediaType, apiPort);
final HealthCheckReport report = invocationBuilder.get(HealthCheckReport.class);
validateHealthCheckReport(NAME, SELF, true, 200, ALIVE, report);
}
@Test
- public void testReadPolicyTypesJson() throws Exception {
+ void testReadPolicyTypesJson() throws Exception {
testReadPolicyTypes(APP_JSON);
}
@Test
- public void testReadPolicyTypesYaml() throws Exception {
+ void testReadPolicyTypesYaml() throws Exception {
testReadPolicyTypes(APP_YAML);
}
}
@Test
- public void testDeletePolicyTypeJson() throws Exception {
+ void testDeletePolicyTypeJson() throws Exception {
testDeletePolicyType(APP_JSON);
}
@Test
- public void testDeletePolicyTypeYaml() throws Exception {
+ void testDeletePolicyTypeYaml() throws Exception {
testDeletePolicyType(APP_YAML);
}
}
@Test
- public void testReadPoliciesJson() throws Exception {
+ void testReadPoliciesJson() throws Exception {
testReadPolicies(APP_JSON);
}
@Test
- public void testReadPoliciesYaml() throws Exception {
+ void testReadPoliciesYaml() throws Exception {
testReadPolicies(APP_YAML);
}
}
@Test
- public void testNamingPolicyGet() throws Exception {
+ void testNamingPolicyGet() throws Exception {
Response rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/"
+ "policies/SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP/versions/1.0.0", APP_JSON, apiPort);
}
@Test
- public void testDeletePoliciesJson() throws Exception {
+ void testDeletePoliciesJson() throws Exception {
testDeletePolicies(APP_JSON);
}
@Test
- public void testDeletePoliciesYaml() throws Exception {
+ void testDeletePoliciesYaml() throws Exception {
testDeletePolicies(APP_YAML);
}
}
@Test
- public void testDeletePolicyVersionJson() throws Exception {
+ void testDeletePolicyVersionJson() throws Exception {
testDeletePolicyVersion(APP_JSON);
}
@Test
- public void testDeletePolicyVersionYaml() throws Exception {
+ void testDeletePolicyVersionYaml() throws Exception {
testDeletePolicyVersion(APP_YAML);
}
}
@Test
- public void testGetAllVersionOfPolicyJson() throws Exception {
+ void testGetAllVersionOfPolicyJson() throws Exception {
testGetAllVersionOfPolicy(APP_JSON);
}
@Test
- public void testGetAllVersionOfPolicyYaml() throws Exception {
+ void testGetAllVersionOfPolicyYaml() throws Exception {
testGetAllVersionOfPolicy(APP_YAML);
}
}
@Test
- public void testGetPoliciesJson() throws Exception {
+ void testGetPoliciesJson() throws Exception {
getPolicies(APP_JSON);
}
@Test
- public void testGetPoliciesYaml() throws Exception {
+ void testGetPoliciesYaml() throws Exception {
getPolicies(APP_YAML);
}
}
@Test
- public void testGetSpecificPolicyJson() throws Exception {
+ void testGetSpecificPolicyJson() throws Exception {
getSpecificPolicy(APP_JSON);
}
@Test
- public void testGetSpecificPolicyYaml() throws Exception {
+ void testGetSpecificPolicyYaml() throws Exception {
getSpecificPolicy(APP_YAML);
}
}
@Test
- public void testDeleteSpecificPolicy() throws Exception {
+ void testDeleteSpecificPolicy() throws Exception {
Response rawResponse;
for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
rawResponse = createResource(POLICYTYPES, resrcName, apiPort);
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.api.main.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.http.ResponseEntity;
/**
* Class to perform unit testing of CommonRestController.
*/
-public class TestCommonRestController {
- private CommonRestController crc = new CommonRestController();
+class TestCommonRestController {
+ private final CommonRestController crc = new CommonRestController();
@Test
- public void testAddLoggingHeaders() {
+ void testAddLoggingHeaders() {
UUID requestId = UUID.randomUUID();
ResponseEntity<Void> rb = crc.makeOkResponse(requestId, null);
- assertEquals(requestId.toString(), rb.getHeaders().getFirst("X-ONAP-RequestID"));
+ Assertions.assertEquals(requestId.toString(), rb.getHeaders().getFirst("X-ONAP-RequestID"));
}
/*
* Tests null response for null object
*/
@Test
- public void testToJsonNull() {
- assertNull(crc.toJson(null));
+ void testToJsonNull() {
+ Assertions.assertNull(crc.toJson(null));
}
}
\ No newline at end of file
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.util.List;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.api.main.PolicyApiApplication;
import org.onap.policy.api.main.rest.utils.CommonTestRestController;
import org.onap.policy.api.main.service.ToscaServiceTemplateService;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* Class to perform unit test of {@link NodeTemplateController}.
*
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = PolicyApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles({ "test", "default" })
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
* @throws IOException on I/O exceptions
* @throws InterruptedException if interrupted
*/
- @BeforeClass
+ @BeforeAll
public static void setupParameters() throws IOException, InterruptedException {
keystore = new SelfSignedKeyStore();
}
* Clean up the database.
*
*/
- @After
+ @AfterEach
public void clearDb() {
for (String name : nodeTemplateKeys) {
try {
@Test
- public void testCreateToscaNodeTemplates() throws Exception {
+ void testCreateToscaNodeTemplates() throws Exception {
Response rawResponse = createResource(NODE_TEMPLATES, TOSCA_NODE_TEMPLATE_RESOURCE, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
@Test
- public void testReadNodeTemplates() throws Exception {
+ void testReadNodeTemplates() throws Exception {
Response rawResponse = readResource(NODE_TEMPLATES, APP_JSON, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
List<?> nodeTemplates = rawResponse.readEntity(List.class);
}
@Test
- public void testUpdateNodeTemplates() throws Exception {
+ void testUpdateNodeTemplates() throws Exception {
createResource(NODE_TEMPLATES, TOSCA_NODE_TEMPLATE_RESOURCE, apiPort);
Response rawResponse = updateResource(NODE_TEMPLATES, TOSCA_UPDATE_NODE_TEMPLATES, APP_JSON, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
}
@Test
- public void testDeleteNodeTemplates() throws Exception {
+ void testDeleteNodeTemplates() throws Exception {
createResource(NODE_TEMPLATES, TOSCA_NODE_TEMPLATE_RESOURCE, apiPort);
Response rawResponse = deleteResource(SPECIFIC_NODE_TEMPLATE, APP_JSON, apiPort);
assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.rest.aaf;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-public class TestAafApiFilter {
- private AafApiFilter aafApiFilter = new AafApiFilter();
+class TestAafApiFilter {
+ private final AafApiFilter aafApiFilter = new AafApiFilter();
@Test
- public void testGetPermissionTypeRoot() {
- assertEquals("org.onap.policy.policy-api", aafApiFilter.getPermissionTypeRoot());
+ void testGetPermissionTypeRoot() {
+ Assertions.assertEquals("org.onap.policy.policy-api", aafApiFilter.getPermissionTypeRoot());
}
}
* ============LICENSE_START=======================================================
* ONAP Policy API
* ================================================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. 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.
import static org.junit.Assert.assertTrue;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
import java.security.SecureRandom;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
/**
* Util class to perform REST unit tests.
- *
*/
public class CommonTestRestController {
protected static final String CONTEXT_PATH = "/policy/api/v1/";
protected void testSwagger(final int apiPort) throws Exception {
- final Invocation.Builder invocationBuilder = sendHttpsRequest(CONTEXT_PATH, "v3/api-docs", APP_JSON, apiPort);
+ final Invocation.Builder invocationBuilder = sendHttpsRequest("v3/api-docs", APP_JSON, apiPort);
final String resp = invocationBuilder.get(String.class);
assertTrue((resp).contains("{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"Policy Framework Lifecycle API\""));
}
ToscaServiceTemplate rawServiceTemplate = getRawServiceTemplate(resourceName);
String mediaType = getMediaType(resourceName);
- mediaType = mediaType == null ? APP_JSON : mediaType;
+ mediaType = mediaType == null ? APP_JSON : mediaType;
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
Entity<ToscaServiceTemplate> entity = Entity.entity(rawServiceTemplate, mediaType);
return invocationBuilder.post(entity);
}
protected Response readResource(String endpoint, String mediaType, int apiPort) throws Exception {
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
return invocationBuilder.get();
}
protected Response deleteResource(String endpoint, String mediaType, int apiPort) throws Exception {
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
return invocationBuilder.delete();
}
ToscaServiceTemplate rawServiceTemplate = getRawServiceTemplate(resourceName);
final Invocation.Builder invocationBuilder;
- invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+ invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
Entity<ToscaServiceTemplate> entity = Entity.entity(rawServiceTemplate, mediaType);
return invocationBuilder.put(entity);
}
}
protected Invocation.Builder sendHttpsRequest(
- final String context, final String endpoint, String mediaType, int apiPort) throws Exception {
+ final String endpoint, String mediaType, int apiPort) throws Exception {
final TrustManager[] noopTrustManager = NetworkUtil.getAlwaysTrustingManager();
client.register(YamlMessageBodyHandler.class);
}
- final WebTarget webTarget = client.target(HTTPS_PREFIX + apiPort + context + endpoint);
+ final WebTarget webTarget = client.target(HTTPS_PREFIX + apiPort + CONTEXT_PATH + endpoint);
final Invocation.Builder invocationBuilder = webTarget.request(mediaType);
} else if (APP_YAML.equals(getMediaType(resourceName))) {
rawServiceTemplate = decodeYaml(resourceName);
}
- return rawServiceTemplate;
+ return rawServiceTemplate;
}
private String getMediaType(String resourceName) {
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.api.main.service;
import java.util.Optional;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.onap.policy.api.main.repository.ToscaServiceTemplateRepository;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@Mock
protected NodeTemplateService nodeTemplateService;
+ AutoCloseable autoCloseable;
+
/**
- * Setup the DB TOSCA service template object post create, and delete request.
- * @param dbSvcTemplate ToscaServiceTemplate object to update
+ * Set up the DB TOSCA service template object post create, and delete request.
+ *
+ * @param dbSvcTemplate ToscaServiceTemplate object to update
* @param svcTemplateFragment the CRUD operation response ToscaServiceTemplate object
- * @param operation the CRUD operation performed
+ * @param operation the CRUD operation performed
*/
protected void mockDbServiceTemplate(ToscaServiceTemplate dbSvcTemplate, ToscaServiceTemplate svcTemplateFragment,
- TestToscaServiceTemplateServiceForPolicyCrud.Operation operation) {
+ TestToscaServiceTemplateServiceForPolicyCrud.Operation operation) {
if (operation != null) {
switch (operation) {
- case CREATE_POLICY_TYPE:
+ case CREATE_POLICY_TYPE -> {
dbSvcTemplate.getPolicyTypes().putAll(svcTemplateFragment.getPolicyTypes());
if (svcTemplateFragment.getDataTypes() != null) {
if (dbSvcTemplate.getDataTypes() == null) {
dbSvcTemplate.getDataTypes().putAll(svcTemplateFragment.getDataTypes());
}
}
- break;
- case DELETE_POLICY_TYPE:
+ }
+ case DELETE_POLICY_TYPE ->
dbSvcTemplate.getPolicyTypes().keySet().removeAll(svcTemplateFragment.getPolicyTypes().keySet());
- break;
- case CREATE_POLICY:
+ case CREATE_POLICY ->
dbSvcTemplate.setToscaTopologyTemplate(svcTemplateFragment.getToscaTopologyTemplate());
- break;
- case DELETE_POLICY:
- dbSvcTemplate.getToscaTopologyTemplate().setPolicies(null);
- break;
- default:
- break;
+ case DELETE_POLICY -> dbSvcTemplate.getToscaTopologyTemplate().setPolicies(null);
+ default -> {
+ }
}
}
Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
/**
* Setup to return empty DB service template.
*/
- @Before
+ @BeforeEach
public void setUp() {
+ autoCloseable = MockitoAnnotations.openMocks(this);
Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.of(new JpaToscaServiceTemplate()));
}
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ autoCloseable.close();
+ }
}
\ No newline at end of file
* ============LICENSE_START=======================================================
* ONAP Policy API
* ================================================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. 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.
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.api.main.repository.NodeTemplateRepository;
import org.onap.policy.api.main.repository.NodeTypeRepository;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
@RunWith(MockitoJUnitRunner.class)
-public class TestNodeTemplateService {
+class TestNodeTemplateService {
@Mock
private NodeTemplateRepository nodeTemplateRepository;
private static final String UPDATED_NODE_TEMPLATE_JSON = "nodetemplates/nodetemplates.metadatasets.update.json";
private static ToscaServiceTemplate updatedToscaServiceTemplate;
- private StandardCoder standardCoder;
- private YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
+ private final YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
ToscaServiceTemplate policyServiceTemplate;
+ AutoCloseable closeable;
+
/**
* Set up for tests.
+ *
* @throws CoderException if error in json parsing
*/
- @Before
+ @BeforeEach
public void setUp() throws CoderException {
- standardCoder = new StandardCoder();
+ closeable = MockitoAnnotations.openMocks(this);
+ StandardCoder standardCoder = new StandardCoder();
policyServiceTemplate =
yamlJsonTranslator.fromYaml(ResourceUtils.getResourceAsString(POLICY_WITH_METADATA_SET_REF),
ToscaServiceTemplate.class);
ToscaServiceTemplate.class);
}
+ @AfterEach
+ void tearDown() throws Exception {
+ closeable.close();
+ }
+
@Test
- public void testVerifyNodeType() {
- assertThatThrownBy(() -> {
- nodeTemplateService.verifyNodeTypeInDbTemplate(new JpaToscaNodeTemplate());
- }).hasMessageMatching("^NODE_TYPE .* for toscaNodeTemplate .* does not exist$");
+ void testVerifyNodeType() {
+ assertThatThrownBy(() -> nodeTemplateService.verifyNodeTypeInDbTemplate(new JpaToscaNodeTemplate()))
+ .hasMessageMatching("^NODE_TYPE .* for toscaNodeTemplate .* does not exist$");
JpaToscaNodeTemplate jpaToscaNodeTemplate = new JpaToscaNodeTemplate();
PfConceptKey nodeType = new PfConceptKey("dummyType", "1.0.0");
}
@Test
- public void testNodeTemplateUsedInPolicy() {
+ void testNodeTemplateUsedInPolicy() {
assertDoesNotThrow(() -> nodeTemplateService.assertNodeTemplateNotUsedInPolicy("dummyName", "1.0.0",
new JpaToscaServiceTemplate(policyServiceTemplate)));
- assertThatThrownBy(() -> {
- nodeTemplateService.assertNodeTemplateNotUsedInPolicy("apexMetadata_decisionMaker", "1.0.0",
- new JpaToscaServiceTemplate(policyServiceTemplate));
- }).hasMessage("Node template is in use, it is referenced in Tosca Policy operational.apex.decisionMaker "
- + "version 1.0.0");
+ assertThatThrownBy(() -> nodeTemplateService
+ .assertNodeTemplateNotUsedInPolicy("apexMetadata_decisionMaker", "1.0.0",
+ new JpaToscaServiceTemplate(policyServiceTemplate)))
+ .hasMessage("Node template is in use, it is referenced in Tosca Policy operational.apex.decisionMaker "
+ + "version 1.0.0");
}
@Test
- public void testNodeTemplateUpdate() throws PfModelException {
+ void testNodeTemplateUpdate() {
Mockito.when(nodeTypeRepository.findById(Mockito.any())).thenReturn(Optional.of(new JpaToscaNodeType()));
Mockito.when(nodeTemplateRepository.findById(Mockito.any())).thenReturn(Optional.of(
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.ArrayList;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.api.main.repository.PdpGroupRepository;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup;
@RunWith(MockitoJUnitRunner.class)
-public class TestPdpGroupService {
+class TestPdpGroupService {
@Mock
private PdpGroupRepository pdpGroupRepository;
@InjectMocks
private PdpGroupService pdpGroupService;
+ AutoCloseable closeable;
+
/**
* Test setup.
+ *
* @throws CoderException decode errors
*/
- @Before
+ @BeforeEach
public void setUp() throws CoderException {
+ closeable = MockitoAnnotations.openMocks(this);
var pdpGroups = new StandardCoder().decode(ResourceUtils.getResourceAsString("pdpgroups/PdpGroups.json"),
PdpGroups.class).getGroups();
List<JpaPdpGroup> jpaPdpGroupList = new ArrayList<>();
when(pdpGroupRepository.findAll()).thenReturn(jpaPdpGroupList);
}
+ @AfterEach
+ void tearDown() throws Exception {
+ closeable.close();
+ }
+
@Test
- public void testAssertPolicyTypeNotSupportedInPdpGroup() {
+ void testAssertPolicyTypeNotSupportedInPdpGroup() {
assertThatCode(() -> pdpGroupService.assertPolicyTypeNotSupportedInPdpGroup("policy_type_not_supported",
"1.0.0")).doesNotThrowAnyException();
}
@Test
- public void testAssertPolicyNotDeployedInPdpGroup() {
+ void testAssertPolicyNotDeployedInPdpGroup() {
assertThatCode(() -> pdpGroupService.assertPolicyNotDeployedInPdpGroup("policy_not_deployed", "1.0.0"))
.doesNotThrowAnyException();
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatCode;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.api.main.repository.PolicyRepository;
import org.onap.policy.models.base.PfConceptKey;
@RunWith(MockitoJUnitRunner.class)
-public class TestPolicyService {
+class TestPolicyService {
@Mock
private PolicyRepository policyRepository;
- @InjectMocks
+ @Mock
private PolicyService policyService;
+ AutoCloseable autoCloseable;
+
+ @BeforeEach
+ void before() {
+ autoCloseable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
+ void after() throws Exception {
+ autoCloseable.close();
+ }
+
@Test
- public void testDeletePolicy() {
+ void testDeletePolicy() {
PfConceptKey id = new PfConceptKey("dummy", "1.0.0");
Mockito.doNothing().when(policyRepository).deleteById(id);
assertThatCode(() -> policyService.deletePolicy(id)).doesNotThrowAnyException();
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatCode;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.api.main.repository.PolicyTypeRepository;
import org.onap.policy.models.base.PfConceptKey;
@RunWith(MockitoJUnitRunner.class)
-public class TestPolicyTypeService {
+class TestPolicyTypeService {
@Mock
private PolicyTypeRepository policyTypeRepository;
@InjectMocks
private PolicyTypeService policyTypeService;
+ AutoCloseable closeable;
+
+ @BeforeEach
+ public void setUp() {
+ closeable = MockitoAnnotations.openMocks(this);
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ closeable.close();
+ }
+
@Test
- public void testDeletePolicy() {
+ void testDeletePolicy() {
PfConceptKey id = new PfConceptKey("dummy", "1.0.0");
Mockito.doNothing().when(policyTypeRepository).deleteById(id);
assertThatCode(() -> policyTypeService.deletePolicyType(id)).doesNotThrowAnyException();
* ============LICENSE_START=======================================================
* ONAP Policy API
* ================================================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. 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.
import static org.junit.Assert.assertTrue;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
@RunWith(MockitoJUnitRunner.class)
-public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServiceTemplateService {
+class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServiceTemplateService {
private static final String NODE_TEMPLATES_JSON = "nodetemplates/nodetemplates.metadatasets.input.tosca.json";
private static final String UPDATED_NODE_TEMPLATE_JSON = "nodetemplates/nodetemplates.metadatasets.update.json";
private static ToscaServiceTemplate toscaServiceTemplate;
private static ToscaServiceTemplate updatedToscaServiceTemplate;
- private StandardCoder standardCoder;
@InjectMocks
private ToscaServiceTemplateService toscaServiceTemplateService;
-
- @Before
+ @BeforeEach
public void setUp() {
super.setUp();
}
*
* @throws CoderException when error parsing the json
*/
- @Before
- public void fetchToscaNodeTemplateJson() throws CoderException {
- standardCoder = new StandardCoder();
+ @BeforeEach
+ void fetchToscaNodeTemplateJson() throws CoderException {
+ StandardCoder standardCoder = new StandardCoder();
toscaServiceTemplate =
standardCoder.decode(ResourceUtils.getResourceAsString(NODE_TEMPLATES_JSON), ToscaServiceTemplate.class);
updatedToscaServiceTemplate =
}
@Test
- public void testToscaNodeTemplatesGet() throws Exception {
+ void testToscaNodeTemplatesGet() throws Exception {
assertNotNull(toscaServiceTemplate);
var createdTemplate = toscaServiceTemplateService.createToscaNodeTemplates(toscaServiceTemplate);
}
@Test
- public void testToscaNodeTemplatesCreate() throws Exception {
+ void testToscaNodeTemplatesCreate() throws Exception {
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.createToscaNodeTemplates(null);
- }).hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
+ assertThatThrownBy(() -> toscaServiceTemplateService.createToscaNodeTemplates(null))
+ .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
ToscaServiceTemplate createdNodeTemplates =
toscaServiceTemplateService.createToscaNodeTemplates(toscaServiceTemplate);
}
@Test
- public void testToscaNodeTemplateUpdate() throws Exception {
+ void testToscaNodeTemplateUpdate() throws Exception {
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.updateToscaNodeTemplates(null);
- }).hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
+ assertThatThrownBy(() -> toscaServiceTemplateService.updateToscaNodeTemplates(null))
+ .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
JpaToscaNodeTemplate jpaNodeTemplate = new JpaToscaNodeTemplate();
PfConceptKey key = new PfConceptKey("apexMetadata_grpc", "1.0.0");
}
@Test
- public void testToscaNodeTemplateDelete() throws Exception {
+ void testToscaNodeTemplateDelete() throws Exception {
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deleteToscaNodeTemplate(null, null);
- }).hasMessageMatching("^name is marked .*on.*ull but is null$");
+ assertThatThrownBy(() -> toscaServiceTemplateService.deleteToscaNodeTemplate(null, null))
+ .hasMessageMatching("^name is marked .*on.*ull but is null$");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deleteToscaNodeTemplate("name", null);
- }).hasMessageMatching("^version is marked .*on.*ull but is null$");
+ assertThatThrownBy(() -> toscaServiceTemplateService.deleteToscaNodeTemplate("name", null))
+ .hasMessageMatching("^version is marked .*on.*ull but is null$");
var createdTemplate = toscaServiceTemplateService.createToscaNodeTemplates(toscaServiceTemplate);
mockDbServiceTemplate(createdTemplate, null, null);
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deleteToscaNodeTemplate("dummyname", "1.0.1");
- }).hasMessage("node template dummyname:1.0.1 not found");
+ assertThatThrownBy(() -> toscaServiceTemplateService.deleteToscaNodeTemplate("dummyname", "1.0.1"))
+ .hasMessage("node template dummyname:1.0.1 not found");
ToscaServiceTemplate responseTemplate =
toscaServiceTemplateService.deleteToscaNodeTemplate("apexMetadata_decisionMaker", "1.0.0");
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020,2022 Bell Canada.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import jakarta.ws.rs.core.Response;
import java.util.Optional;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
* @author Chenfei Gao (cgao@research.att.com)
*/
@RunWith(MockitoJUnitRunner.class)
-public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonToscaServiceTemplateService {
+class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonToscaServiceTemplateService {
- private static StandardCoder standardCoder = new StandardCoder();
- private static StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
+ private static final StandardCoder standardCoder = new StandardCoder();
+ private static final StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
private static final String POLICY_RESOURCE = "policies/vCPE.policy.monitoring.input.tosca.json";
private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.monitoring.tcagen2.yaml";
@InjectMocks
private ToscaServiceTemplateService toscaServiceTemplateService;
- @Before
+ @BeforeEach
public void setUp() {
super.setUp();
}
@Test
- public void testFetchPolicies() {
+ void testFetchPolicies() {
Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.empty());
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", null, null, null);
- }).hasMessage("service template not found in database");
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", null, null, null))
+ .hasMessage("service template not found in database");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", null, null);
- }).hasMessage("service template not found in database");
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", null, null))
+ .hasMessage("service template not found in database");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0", null);
- }).hasMessage("service template not found in database");
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0", null))
+ .hasMessage("service template not found in database");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchPolicies(null, null, "dummy", "1.0.0", null);
- }).hasMessage("service template not found in database");
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies(null, null, "dummy", "1.0.0", null))
+ .hasMessage("service template not found in database");
}
@Test
- public void testFetchLatestPolicies() {
+ void testFetchLatestPolicies() {
Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.empty());
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchLatestPolicies("dummy", "dummy", "dummy", null);
- }).hasMessage("service template not found in database");
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchLatestPolicies("dummy", "dummy", "dummy", null))
+ .hasMessage("service template not found in database");
}
@Test
- public void testCreatePolicy() throws Exception {
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.createPolicy("dummy", "1.0.0", new ToscaServiceTemplate());
- }).hasMessage("topology template not specified on service template");
+ void testCreatePolicy() throws Exception {
+ assertThatThrownBy(() -> toscaServiceTemplateService
+ .createPolicy("dummy", "1.0.0", new ToscaServiceTemplate()))
+ .hasMessage("topology template not specified on service template");
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
}
@Test
- public void testCreateOperationalDroolsPolicy() throws CoderException {
+ void testCreateOperationalDroolsPolicy() throws CoderException {
var policyTypeServiceTemplate = standardYamlCoder.decode(
ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
}
@Test
- public void testSimpleCreatePolicy() throws Exception {
+ void testSimpleCreatePolicy() throws Exception {
assertThatThrownBy(() -> {
String multiPoliciesString = ResourceUtils.getResourceAsString(MULTIPLE_POLICIES_RESOURCE);
}
@Test
- public void testDeletePolicy() throws CoderException, PfModelException {
+ void testDeletePolicy() throws CoderException {
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deletePolicy("dummy", "1.0.0", "dummy", "1.0.0");
- }).hasMessage("no policies found");
+ assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicy("dummy", "1.0.0", "dummy", "1.0.0"))
+ .hasMessage("no policies found");
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
var exceptionMessage = "policy is in use, it is deployed in PDP group dummy subgroup dummy";
Mockito.doThrow(new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, exceptionMessage))
.when(pdpGroupService).assertPolicyNotDeployedInPdpGroup("onap.restart.tca", "1.0.0");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
- "onap.restart.tca", "1.0.0");
- }).hasMessage(exceptionMessage);
+ assertThatThrownBy(() -> toscaServiceTemplateService
+ .deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0"))
+ .hasMessage(exceptionMessage);
+
Mockito.doNothing().when(pdpGroupService).assertPolicyNotDeployedInPdpGroup("onap.restart.tca", "1.0.0");
var deletePolicyResponseFragment = toscaServiceTemplateService
assertFalse(deletePolicyResponseFragment.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
mockDbServiceTemplate(serviceTemplate, deletePolicyResponseFragment, Operation.DELETE_POLICY);
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
- "onap.restart.tca", "1.0.0");
- }).hasMessageContaining("no policies found");
+ assertThatThrownBy(() -> toscaServiceTemplateService
+ .deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0"))
+ .hasMessageContaining("no policies found");
}
@Test
- public void testFetchAllPolicies() throws Exception {
+ void testFetchAllPolicies() throws Exception {
// Create Policy Type
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
}
@Test
- public void testFetchSpecificPolicy_availablePolicy() throws Exception {
+ void testFetchSpecificPolicy_availablePolicy() throws Exception {
// Create Policy Type
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
}
@Test
- public void testFetchSpecificPolicy_unavailablePolicy() throws Exception {
+ void testFetchSpecificPolicy_unavailablePolicy() throws Exception {
// Create Policy Type
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
}
@Test
- public void testDeleteSpecificPolicy_availablePolicy() throws Exception {
+ void testDeleteSpecificPolicy_availablePolicy() throws Exception {
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
}
@Test
- public void testDeleteSpecificPolicy_unavailablePolicy() throws Exception {
+ void testDeleteSpecificPolicy_unavailablePolicy() throws Exception {
var policyTypeServiceTemplate = standardYamlCoder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
+import jakarta.ws.rs.core.Response;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
* @author Chenfei Gao (cgao@research.att.com)
*/
@RunWith(MockitoJUnitRunner.class)
-public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommonToscaServiceTemplateService {
+class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommonToscaServiceTemplateService {
- private static StandardYamlCoder coder = new StandardYamlCoder();
+ private static final StandardYamlCoder coder = new StandardYamlCoder();
private static final String POLICY_TYPE_VERSION = "1.0.0";
private static final String POLICY_RESOURCE_MONITORING = "policies/vCPE.policy.monitoring.input.tosca.yaml";
/**
* Test setup.
*/
- @Before
+ @BeforeEach
public void setUp() {
super.setUp();
}
@Test
- public void testFetchPolicyTypes() throws PfModelException {
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchPolicyTypes("dummy", null);
- }).hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=null) do not exist");
+ void testFetchPolicyTypes() {
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicyTypes("dummy", null))
+ .hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=null) do not exist");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchPolicyTypes("dummy", "dummy");
- }).hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=dummy) do not exist");
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicyTypes("dummy", "dummy"))
+ .hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=dummy) do not exist");
// FIXME
// ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(null, null);
}
@Test
- public void testFetchLatestPolicyTypes() {
-
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.fetchLatestPolicyTypes("dummy");
- }).hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=LATEST) do not exist");
+ void testFetchLatestPolicyTypes() {
+ assertThatThrownBy(() -> toscaServiceTemplateService.fetchLatestPolicyTypes("dummy"))
+ .hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=LATEST) do not exist");
}
@Test
- public void testCreatePolicyType() throws CoderException {
+ void testCreatePolicyType() throws CoderException {
var policyTypeServiceTemplate = coder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_MONITORING), ToscaServiceTemplate.class);
var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
policyTypeServiceTemplate.getPolicyTypes().get("onap.policies.monitoring.tcagen2")
.setDescription("Some other description");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
- }).hasMessageContaining("item \"entity\" value \"onap.policies.monitoring.tcagen2:1.0.0\" INVALID, "
- + "does not equal existing entity");
+ assertThatThrownBy(() -> toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate))
+ .hasMessageContaining("item \"entity\" value \"onap.policies.monitoring.tcagen2:1.0.0\" INVALID, "
+ + "does not equal existing entity");
assertThatThrownBy(() -> {
ToscaServiceTemplate badPolicyType =
}
@Test
- public void testCreateOperationalPolicyTypes() throws CoderException {
+ void testCreateOperationalPolicyTypes() throws CoderException {
ToscaServiceTemplate policyTypeServiceTemplate = coder.decode(
ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
}
@Test
- public void testCreateApexOperationalPolicyTypes() throws CoderException {
+ void testCreateApexOperationalPolicyTypes() throws CoderException {
var policyTypeServiceTemplate = coder.decode(
ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
}
@Test
- public void testDeletePolicyType() throws CoderException {
+ void testDeletePolicyType() throws CoderException {
var policyTypeServiceTemplate = coder
.decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_MONITORING), ToscaServiceTemplate.class);
var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
mockDbServiceTemplate(serviceTemplate, createPolicyResponseFragment, Operation.CREATE_POLICY);
var exceptionMessage = "policy type onap.policies.monitoring.tcagen2:1.0.0 is in use, "
+ "it is referenced in policy onap.restart.tca:1.0.0";
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2", "1.0.0");
- }).hasMessage(exceptionMessage);
+ assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2",
+ "1.0.0")).hasMessage(exceptionMessage);
var deletePolicyResponseFragment = toscaServiceTemplateService
.deletePolicy("onap.policies.monitoring.tcagen2", "1.0.0", "onap.restart.tca", "1.0.0");
exceptionMessage = "policy type is in use, it is referenced in PDP group dummy subgroup dummy";
Mockito.doThrow(new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, exceptionMessage))
.when(pdpGroupService).assertPolicyTypeNotSupportedInPdpGroup("onap.policies.monitoring.tcagen2", "1.0.0");
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2", "1.0.0");
- }).hasMessage(exceptionMessage);
+ assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2",
+ "1.0.0")).hasMessage(exceptionMessage);
Mockito.doNothing().when(pdpGroupService)
.assertPolicyTypeNotSupportedInPdpGroup("onap.policies.monitoring.tcagen2", "1.0.0");
assertFalse(deletePolicyTypeResponseFragment.getPolicyTypes().isEmpty());
mockDbServiceTemplate(serviceTemplate, deletePolicyTypeResponseFragment, Operation.DELETE_POLICY_TYPE);
- assertThatThrownBy(() -> {
- toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2", "1.0.0");
- }).hasMessage("policy type onap.policies.monitoring.tcagen2:1.0.0 not found");
+ assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2",
+ "1.0.0")).hasMessage("policy type onap.policies.monitoring.tcagen2:1.0.0 not found");
}
}
\ No newline at end of file
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatCode;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.policy.api.main.PolicyApiApplication;
import org.onap.policy.api.main.config.PolicyPreloadConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = PolicyApiApplication.class)
@ActiveProfiles("test")
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
-public class ApiDatabaseInitializerTest {
+class ApiDatabaseInitializerTest {
@Autowired
private PolicyPreloadConfig params;
private ApiDatabaseInitializer adi;
@Test
- public void testInitializeApiDatabase() {
+ void testInitializeApiDatabase() {
assertThatCode(() -> adi.initializeApiDatabase(params.getPolicyTypes(),
params.getPolicies())).doesNotThrowAnyException();
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2020 Nordix Foundation.
+ Copyright (C) 2019-2020, 2023 Nordix Foundation.
Modifications Copyright (C) 2021 AT&T Intellectual Property.
Modifications Copyright (C) 2023 Bell Canada. All rights reserved.
================================================================================
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
<properties>
- <property name="javax.persistence.schema-generation.database.action" value="create" />
+ <property name="jakarta.persistence.schema-generation.database.action" value="create" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />
================================================================================
Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
<version>4.0.0-SNAPSHOT</version>
- <relativePath />
+ <relativePath/>
</parent>
<groupId>org.onap.policy.api</groupId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>policy-endpoints</artifactId>
<version>${policy.common.version}</version>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
</dependency>
+
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
+ <artifactId>jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</dependency>
<dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet</artifactId>
- <version>${version.jersey}</version>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
</dependency>
</dependencies>