private StartupService startupService;
public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
+ SpringApplication.run(Application.class);
}
/**
private Mono<Object> validateModifiedPolicy(Policy policy) {
// Check that ric is not updated
Policy current = this.policies.get(policy.id());
- if (current != null) {
- if (!current.ric().name().equals(policy.ric().name())) {
- return Mono.error(new Exception("Policy cannot change RIC, policyId: " + current.id() + //
- ", RIC name: " + current.ric().name() + //
- ", new name: " + policy.ric().name()));
- }
+ if (current != null && !current.ric().name().equals(policy.ric().name())) {
+ return Mono.error(new Exception("Policy cannot change RIC, policyId: " + current.id() + //
+ ", RIC name: " + current.ric().name() + //
+ ", new name: " + policy.ric().name()));
}
return Mono.just("OK");
}
private static final Logger logger = LoggerFactory.getLogger(DmaapMessageConsumer.class);
+ @SuppressWarnings("squid:S00116") // To avoid warning about DMAAP abbreviation.
final Duration TIME_BETWEEN_DMAAP_POLLS = Duration.ofSeconds(10);
+
private final ApplicationConfig applicationConfig;
@Value("${server.port}")
package org.oransc.policyagent.repository;
-import java.util.ArrayList;
+import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Vector;
public class Ric {
private final RicConfig ricConfig;
- private final List<String> managedElementIds;
+ private final ImmutableList<String> managedElementIds;
private RicState state = RicState.UNDEFINED;
private Map<String, PolicyType> supportedPolicyTypes = new HashMap<>();
*/
public Ric(RicConfig ricConfig) {
this.ricConfig = ricConfig;
- this.managedElementIds = new ArrayList<>(ricConfig.managedElementIds()); // TODO, this is config why is it
- // copied here?
+ this.managedElementIds = ricConfig.managedElementIds();
}
public String name() {
return managedElementIds.contains(managedElementId);
}
- /**
- * Adds the given node as managed by this Ric.
- *
- * @param managedElementId the node to add.
- */
- public synchronized void addManagedElement(String managedElementId) {
- if (!managedElementIds.contains(managedElementId)) {
- managedElementIds.add(managedElementId);
- }
- }
-
- /**
- * Removes the given node as managed by this Ric.
- *
- * @param managedElementId the node to remove.
- */
- public synchronized void removeManagedElement(String managedElementId) {
- managedElementIds.remove(managedElementId);
- }
-
/**
* Gets the policy types supported by this Ric.
*
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.AfterEach;
@Test
public void testGetRicForManagedElement_thenReturnCorrectRic() throws Exception {
String ricName = "ric1";
- Ric ric = addRic(ricName);
String managedElementId = "kista_1";
- ric.addManagedElement(managedElementId);
+ addRic(ricName, managedElementId);
String url = baseUrl() + "/ric?managedElementId=" + managedElementId;
String rsp = this.restTemplate.getForObject(url, String.class);
this.supervision = supervision;
}
+ @Override
public void run() {
for (int i = 0; i < 100; ++i) {
if (i % 10 == 0) {
}
private Ric addRic(String ricName) {
+ return addRic(ricName, null);
+ }
+
+ private Ric addRic(String ricName, String managedElement) {
if (rics.get(ricName) != null) {
return rics.get(ricName);
}
- Vector<String> mes = new Vector<>();
+ List<String> mes = new ArrayList<>();
+ if (managedElement != null) {
+ mes.add(managedElement);
+ }
RicConfig conf = ImmutableRicConfig.builder() //
.name(ricName) //
.baseUrl(ricName) //