/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.assertEquals;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.models.sim.pdp.PdpSimulatorActivator;
import org.onap.policy.models.sim.pdp.PdpSimulatorCommandLineArguments;
import org.onap.policy.models.sim.pdp.PdpSimulatorConstants;
-import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
import org.onap.policy.models.sim.pdp.parameters.PdpSimulatorParameterGroup;
import org.onap.policy.models.sim.pdp.parameters.PdpSimulatorParameterHandler;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
public class TestPdpStateChangeListener {
+ private static final String PDP_SUBGROUP = "pdpSubgroup";
+ private static final String PDP_GROUP = "pdpGroup";
private PdpUpdateListener pdpUpdateMessageListener;
private PdpStateChangeListener pdpStateChangeListener;
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
/**
* Method for setup before each test.
*
- * @throws PdpSimulatorException if some error occurs while starting up the pdp simulator
- * @throws FileNotFoundException if the file is missing
- * @throws IOException if IO exception occurs
+ * @throws Exception if an error occurs
*/
@Before
- public void setUp() throws PdpSimulatorException, FileNotFoundException, IOException {
+ public void setUp() throws Exception {
pdpUpdateMessageListener = new PdpUpdateListener();
pdpStateChangeListener = new PdpStateChangeListener();
Registry.newRegistry();
private PdpUpdate performPdpUpdate(final String instance) {
final PdpUpdate pdpUpdateMsg = new PdpUpdate();
pdpUpdateMsg.setDescription("dummy pdp status for test");
- pdpUpdateMsg.setPdpGroup("pdpGroup");
- pdpUpdateMsg.setPdpSubgroup("pdpSubgroup");
+ pdpUpdateMsg.setPdpGroup(PDP_GROUP);
+ pdpUpdateMsg.setPdpSubgroup(PDP_SUBGROUP);
pdpUpdateMsg.setName(instance);
final ToscaPolicy toscaPolicy = new ToscaPolicy();
toscaPolicy.setType("apexpolicytype");
propertiesMap.put("content", "");
}
toscaPolicy.setProperties(propertiesMap);
- final List<ToscaPolicy> toscaPolicies = new ArrayList<ToscaPolicy>();
+ final List<ToscaPolicy> toscaPolicies = new ArrayList<>();
toscaPolicies.add(toscaPolicy);
pdpUpdateMsg.setPolicies(toscaPolicies);
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
performPdpUpdate(pdpStatus.getName());
final PdpStateChange pdpStateChangeMsg = new PdpStateChange();
pdpStateChangeMsg.setState(PdpState.PASSIVE);
- pdpStateChangeMsg.setPdpGroup("pdpGroup");
- pdpStateChangeMsg.setPdpSubgroup("pdpSubgroup");
+ pdpStateChangeMsg.setPdpGroup(PDP_GROUP);
+ pdpStateChangeMsg.setPdpSubgroup(PDP_SUBGROUP);
pdpStateChangeMsg.setName(pdpStatus.getName());
pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg);
pdpStatus.setState(PdpState.ACTIVE);
final PdpStateChange pdpStateChangeMsg = new PdpStateChange();
pdpStateChangeMsg.setState(PdpState.ACTIVE);
- pdpStateChangeMsg.setPdpGroup("pdpGroup");
- pdpStateChangeMsg.setPdpSubgroup("pdpSubgroup");
+ pdpStateChangeMsg.setPdpGroup(PDP_GROUP);
+ pdpStateChangeMsg.setPdpSubgroup(PDP_SUBGROUP);
pdpStateChangeMsg.setName(pdpStatus.getName());
pdpStateChangeListener.onTopicEvent(INFRA, TOPIC, null, pdpStateChangeMsg);