package org.onap.policy.pap.main;
+import org.onap.policy.common.utils.network.NetworkUtil;
+
/**
* Names of various items contained in the Registry.
*/
public static final String POLICY_PAP = "pap";
public static final String POLICY_PDPS = "pdps";
+ // unique name used when generating PdpMessages
+ public static final String PAP_NAME = NetworkUtil.genUniqueName("pap");
+
private PapConstants() {
super();
}
final var update = new PdpUpdate();
+ update.setSource(PapConstants.PAP_NAME);
update.setName(pdpInstanceId);
update.setPdpGroup(pdpGroupName);
update.setPdpSubgroup(subGroup.getPdpType());
final String pdpInstanceId, final PdpState pdpState) {
final var stateChange = new PdpStateChange();
+ stateChange.setSource(PapConstants.PAP_NAME);
stateChange.setName(pdpInstanceId);
stateChange.setPdpGroup(pdpGroupName);
stateChange.setPdpSubgroup(subGroup.getPdpType());
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.pap.main.PapConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// make it passive
var change = new PdpStateChange();
+ change.setSource(PapConstants.PAP_NAME);
change.setName(name);
change.setState(PdpState.PASSIVE);
// remove it from subgroup and undeploy all policies
var update = new PdpUpdate();
+ update.setSource(PapConstants.PAP_NAME);
update.setName(name);
data.addRequests(update, change);
var update = new PdpUpdate();
+ update.setSource(PapConstants.PAP_NAME);
update.setName(pdp.getInstanceId());
update.setDescription(group.getDescription());
update.setPdpGroup(group.getName());
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.pap.main;
-import org.assertj.core.api.Assertions;
+import static org.assertj.core.api.Assertions.assertThat;
+
import org.junit.Test;
-import org.powermock.reflect.Whitebox;
public class PapConstantsTest {
@Test
public void test() {
- // verify that constructor does not throw an exception
- Assertions.assertThatCode(() -> Whitebox.invokeConstructor(PapConstants.class)).doesNotThrowAnyException();
+ assertThat(PapConstants.PAP_NAME).startsWith("pap").isNotEqualTo("pap");
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.pap.main.PapConstants;
public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
private static final String EXPECTED_EXCEPTION = "expected exception";
assertEquals(2, pdpUpdates.size());
PdpUpdate pdpUpdate = pdpUpdates.get(0);
+ assertEquals(PapConstants.PAP_NAME, pdpUpdate.getSource());
assertEquals(PDP2, pdpUpdate.getName());
assertNull(pdpUpdate.getPdpGroup());
pdpUpdate = pdpUpdates.get(1);
+ assertEquals(PapConstants.PAP_NAME, pdpUpdate.getSource());
assertEquals(PDP4, pdpUpdate.getName());
assertNull(pdpUpdate.getPdpGroup());
assertEquals(2, changes.size());
PdpStateChange change = changes.get(0);
+ assertEquals(PapConstants.PAP_NAME, change.getSource());
assertEquals(PDP2, change.getName());
assertEquals(PdpState.PASSIVE, change.getState());
change = changes.get(1);
+ assertEquals(PapConstants.PAP_NAME, change.getSource());
assertEquals(PDP4, change.getName());
assertEquals(PdpState.PASSIVE, change.getState());
}
assertNoGroupAction();
}
- protected void assertUpdate(List<PdpUpdate> updates, String groupName, String pdpType, String pdpName) {
-
- PdpUpdate update = updates.remove(0);
-
- assertEquals(groupName, update.getPdpGroup());
- assertEquals(pdpType, update.getPdpSubgroup());
- assertEquals(pdpName, update.getName());
- assertTrue(update.getPoliciesToBeDeployed().contains(policy1));
- }
-
private void assertNoGroupAction() throws Exception {
verify(dao, never()).createPdpGroups(any());
verify(dao, never()).updatePdpGroups(any());
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.pap.main.PapConstants;
import org.powermock.reflect.Whitebox;
public class TestProviderBase extends ProviderSuper {
PdpUpdate update = updates.remove(0);
+ assertEquals(PapConstants.PAP_NAME, update.getSource());
assertEquals(groupName, update.getPdpGroup());
assertEquals(pdpType, update.getPdpSubgroup());
assertEquals(pdpName, update.getName());