/.classpath
/.project
/.settings
-/target/
+target
/.mvn/wrapper/maven-wrapper.jar
/.tox
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.oransc</groupId>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>2.1.6.RELEASE</version>
+ <relativePath />
+ </parent>
+ <groupId>org.o-ran-sc.nonrtric</groupId>
<artifactId>policy-agent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<licenses>
<url>https://nexus.onap.org/content/repositories/releases/</url>
</repository>
</repositories>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.1.6.RELEASE</version>
- <relativePath />
- </parent>
+ <properties>
+ <java.version>11</java.version>
+ <springfox.version>2.8.0</springfox.version>
+ <immutable.version>2.7.1</immutable.version>
+ <sdk.version>1.1.6</sdk.version>
+ <swagger.version>2.0.0</swagger.version>
+ <json.version>20180130</json.version>
+ <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
+ <formatter-maven-plugin.version>2.8.1</formatter-maven-plugin.version>
+ <spotless-maven-plugin.version>1.18.0</spotless-maven-plugin.version>
+ <dockerfile-maven-plugin.version>1.4.13</dockerfile-maven-plugin.version>
+ </properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2</artifactId>
- <version>2.0.0</version>
+ <version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
- <version>2.0.0</version>
+ <version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>org.immutables</groupId>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
- <version>20180130</version>
+ <version>${json.version}</version>
</dependency>
<!--TEST -->
<dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
- <version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-configuration-processor</artifactId>
+ <optional>true</optional>
+ </dependency>
</dependencies>
- <properties>
- <java.version>11</java.version>
- <springfox.version>2.8.0</springfox.version>
- <immutable.version>2.7.1</immutable.version>
- <sdk.version>1.1.6</sdk.version>
- <junit-jupiter.version>5.4.0</junit-jupiter.version>
- </properties>
<build>
<plugins>
<plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
- <version>2.8.1</version>
+ <version>${formatter-maven-plugin.version}</version>
<configuration>
<configFile>${project.basedir}/eclipse-formatter.xml</configFile>
</configuration>
- <!-- https://code.revelc.net/formatter-maven-plugin/ use
- mvn formatter:format spotless:apply process-sources -->
+ <!-- https://code.revelc.net/formatter-maven-plugin/ use
+ mvn formatter:format spotless:apply process-sources -->
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
- <version>1.18.0</version>
+ <version>${spotless-maven-plugin.version}</version>
<configuration>
<java>
- <removeUnusedImports/>
+ <removeUnusedImports />
<importOrder>
<order>com,java,javax,org</order>
</importOrder>
</java>
</configuration>
- <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven use
- mvn spotless:apply to rewrite source files use mvn spotless:check to validate
- source files -->
+ <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
+ use mvn spotless:apply to rewrite source files use mvn spotless:check to
+ validate source files -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.17</version>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>dockerfile-maven-plugin</artifactId>
- <configuration>
- <repository>oransc/policy-agent</repository>
- <tag>${project.version}</tag>
- <buildArgs>
- <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
- </buildArgs>
- </configuration>
- </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>${dockerfile-maven-plugin.version}</version>
+ <configuration>
+ <repository>oransc/policy-agent</repository>
+ <tag>${project.version}</tag>
+ <buildArgs>
+ <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
+ </buildArgs>
+ </configuration>
+ </plugin>
</plugins>
</build>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://jira.o-ran-sc.org/</url>
+ </issueManagement>
</project>
/**
* Starts the service and reads the configuration.
*
- * @param ctx
- * @return
+ * @param ctx the application context.
+ *
+ * @return the command line runner performing tasks at startup.
*/
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.clients;
+
+
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
InputStream createInputStream(@NotNull String filepath) throws IOException {
return new BufferedInputStream(new FileInputStream(filepath));
}
-
}
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.controllers;
import com.google.gson.Gson;
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.policyagent.controllers;
+package org.oransc.policyagent.controllers;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.policyagent.controllers;
+package org.oransc.policyagent.controllers;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.policyagent.controllers;
+package org.oransc.policyagent.controllers;
import java.util.Vector;
import org.immutables.gson.Gson;
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.controllers;
import com.google.gson.Gson;
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.policyagent.controllers;
+package org.oransc.policyagent.controllers;
import org.immutables.gson.Gson;
import org.immutables.value.Value;
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.controllers;
import com.google.gson.annotations.SerializedName;
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.controllers;
import io.swagger.annotations.ApiOperation;
import java.util.Vector;
import org.oransc.policyagent.exceptions.ServiceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class Policies {
- private static final Logger logger = LoggerFactory.getLogger(Policies.class);
-
private Map<String, Policy> policiesId = new HashMap<>();
private Map<String, Map<String, Policy>> policiesRic = new HashMap<>();
private Map<String, Map<String, Policy>> policiesService = new HashMap<>();
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.repository;
import org.immutables.gson.Gson;
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent.repository;
import java.time.Duration;
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.List;
import java.util.Vector;
-import org.junit.Test;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.oransc.policyagent.configuration.ApplicationConfig;
import org.oransc.policyagent.configuration.ImmutableRicConfig;
import org.oransc.policyagent.configuration.RicConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.client.RestTemplate;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ApplicationTest {
}
/**
- * overrides the BeanFactory
+ * Overrides the BeanFactory.
*/
@TestConfiguration
static class TestBeanFactory {
private final RestTemplate restTemplate = new RestTemplate();
- @BeforeEach
- public void reset() {
+ private void reset() {
rics.clear();
policies.clear();
policyTypes.clear();
assertThat(policies.size()).isEqualTo(0);
}
- public static <T> List<T> parseList(String json, Class<T> clazz) {
+ private static <T> List<T> parseList(String json, Class<T> clazz) {
if (null == json) {
return null;
}
@Test
public void testGetPolicyTypes() throws Exception {
- String url = baseUrl() + "/policy_types";
reset();
addPolicy("id1", "type1", "service1");
addPolicy("id2", "type2", "service2");
+ String url = baseUrl() + "/policy_types";
String rsp = this.restTemplate.getForObject(url, String.class);
System.out.println(rsp);
assertThat(rsp).contains("type1");
* limitations under the License.
* ========================LICENSE_END===================================
*/
+
package org.oransc.policyagent;
import com.google.gson.JsonObject;
package org.oransc.policyagent.configuration;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
package org.oransc.policyagent.tasks;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
verify(ricClientMock).getPolicyTypes(SECOND_RIC_URL);
verifyNoMoreInteractions(ricClientMock);
- assertEquals("Not correct number of policy types added.", 2, policyTypes.size());
- assertEquals("Not correct type added.", type1, policyTypes.getType(POLICY_TYPE_1_NAME));
- assertEquals("Not correct type added.", type2, policyTypes.getType(POLICY_TYPE_2_NAME));
- assertEquals("Correct nymber of Rics not added to Rics", 2, rics.size());
+ assertEquals(2, policyTypes.size(), "Not correct number of policy types added.");
+ assertEquals(type1, policyTypes.getType(POLICY_TYPE_1_NAME), "Not correct type added.");
+ assertEquals(type2, policyTypes.getType(POLICY_TYPE_2_NAME), "Not correct type added.");
+ assertEquals(2, rics.size(), "Correct nymber of Rics not added to Rics");
Ric firstRic = rics.getRic(FIRST_RIC_NAME);
- assertNotNull("Ric \"" + FIRST_RIC_NAME + "\" not added to repositpry", firstRic);
- assertEquals("Not correct Ric \"" + FIRST_RIC_NAME + "\" added to Rics", FIRST_RIC_NAME, firstRic.name());
- assertEquals("Not correct state for \"" + FIRST_RIC_NAME + "\"", ACTIVE, firstRic.state());
- assertEquals("Not correct no of types supported", 1, firstRic.getSupportedPolicyTypes().size());
- assertTrue("Not correct type supported", firstRic.isSupportingType(type1));
- assertEquals("Not correct no of managed nodes", 1, firstRic.getManagedNodes().size());
- assertTrue("Not managed by node", firstRic.isManaging(MANAGED_NODE_A));
+ assertNotNull(firstRic, "Ric \"" + FIRST_RIC_NAME + "\" not added to repositpry");
+ assertEquals(FIRST_RIC_NAME, firstRic.name(), "Not correct Ric \"" + FIRST_RIC_NAME + "\" added to Rics");
+ assertEquals(ACTIVE, firstRic.state(), "Not correct state for \"" + FIRST_RIC_NAME + "\"");
+ assertEquals(1, firstRic.getSupportedPolicyTypes().size(), "Not correct no of types supported");
+ assertTrue(firstRic.isSupportingType(type1), "Not correct type supported");
+ assertEquals(1, firstRic.getManagedNodes().size(), "Not correct no of managed nodes");
+ assertTrue(firstRic.isManaging(MANAGED_NODE_A), "Not managed by node");
Ric secondRic = rics.getRic(SECOND_RIC_NAME);
- assertNotNull("Ric \"" + SECOND_RIC_NAME + "\" not added to repositpry", secondRic);
- assertEquals("Not correct Ric \"" + SECOND_RIC_NAME + "\" added to Rics", SECOND_RIC_NAME, secondRic.name());
- assertEquals("Not correct state for \"" + SECOND_RIC_NAME + "\"", ACTIVE, secondRic.state());
- assertEquals("Not correct no of types supported", 2, secondRic.getSupportedPolicyTypes().size());
- assertTrue("Not correct type supported", secondRic.isSupportingType(type1));
- assertTrue("Not correct type supported", secondRic.isSupportingType(type2));
- assertEquals("Not correct no of managed nodes", 2, secondRic.getManagedNodes().size());
- assertTrue("Not correct managed node", secondRic.isManaging(MANAGED_NODE_B));
- assertTrue("Not correct managed node", secondRic.isManaging(MANAGED_NODE_C));
+ assertNotNull(secondRic, "Ric \"" + SECOND_RIC_NAME + "\" not added to repositpry");
+ assertEquals(SECOND_RIC_NAME, secondRic.name(), "Not correct Ric \"" + SECOND_RIC_NAME + "\" added to Rics");
+ assertEquals(ACTIVE, secondRic.state(), "Not correct state for \"" + SECOND_RIC_NAME + "\"");
+ assertEquals(2, secondRic.getSupportedPolicyTypes().size(), "Not correct no of types supported");
+ assertTrue(secondRic.isSupportingType(type1), "Not correct type supported");
+ assertTrue(secondRic.isSupportingType(type2), "Not correct type supported");
+ assertEquals(2, secondRic.getManagedNodes().size(), "Not correct no of managed nodes");
+ assertTrue(secondRic.isManaging(MANAGED_NODE_B), "Not correct managed node");
+ assertTrue(secondRic.isManaging(MANAGED_NODE_C), "Not correct managed node");
}
private RicConfig getRicConfig(String name, String baseUrl, String... nodeNames) {
============LICENSE_END=========================================================
-->
<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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <groupId>org.oransc</groupId>
- <artifactId>nonrtric</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
+ <groupId>org.o-ran-sc</groupId>
+ <artifactId>nonrtric</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
- <name>nonrtric</name>
- <modules>
- <module>dashboard</module>
- <module>near-rt-ric-simulator</module>
- <module>sdnc-a1-controller</module>
- <module>policy-agent</module>
- </modules>
-</project>
+ <name>nonrtric</name>
+ <modules>
+ <module>policy-agent</module>
+ <module>dashboard</module>
+ <module>near-rt-ric-simulator</module>
+ </modules>
+ </project>