aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-simulator
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator')
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java1
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java111
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java94
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java13
6 files changed, 116 insertions, 107 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
index b872ec0c6..5a6dbfa81 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
@@ -92,6 +92,8 @@ public abstract class AbstractRestController {
/**
* create a Rest Controller.
+ *
+ * @param simulationProvider the provider for the simulation participant
*/
protected AbstractRestController(SimulationProvider simulationProvider) {
this.simulationProvider = simulationProvider;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
index 6ee4eac3e..49338c2b0 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
@@ -41,6 +41,7 @@ public class SimulationProvider {
/**
* Create a participant simulation provider.
+ * @param intermediaryApi the intermediary to use for talking to the CLAMP runtime
*/
public SimulationProvider(ParticipantIntermediaryApi intermediaryApi) {
this.intermediaryApi = intermediaryApi;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
index de2a06223..e0569cf0f 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
@@ -68,40 +68,42 @@ public class SimulationElementController extends AbstractRestController {
*/
// @formatter:off
@GetMapping("/elements/{name}/{version}")
- @ApiOperation(value = "Query details of the requested simulated control loop elements",
- notes = "Queries details of the requested simulated control loop elements, "
- + "returning all control loop element details",
- response = ControlLoops.class,
- tags = {
- "Clamp Control Loop Participant Simulator API"
- },
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
+ @ApiOperation(
+ value = "Query details of the requested simulated control loop elements",
+ notes = "Queries details of the requested simulated control loop elements, "
+ + "returning all control loop element details",
+ response = ControlLoops.class,
+ tags = {
+ "Clamp Control Loop Participant Simulator API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
public ResponseEntity<Map<UUID, ControlLoopElement>> elements(
@@ -134,31 +136,32 @@ public class SimulationElementController extends AbstractRestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
index 715ec3410..25ae4ac22 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
@@ -76,39 +76,38 @@ public class SimulationParticipantController extends AbstractRestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
}
)
// @formatter:on
public ResponseEntity<List<Participant>> participants(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Participant name", required = true) @PathVariable("name") String name,
- @ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) {
+ @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Participant name", required = true) @PathVariable("name") String name,
+ @ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) {
return ResponseEntity.ok().body(getSimulationProvider().getParticipants(name, version));
}
@@ -131,31 +130,32 @@ public class SimulationParticipantController extends AbstractRestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
@@ -167,10 +167,8 @@ public class SimulationParticipantController extends AbstractRestController {
)
// @formatter:on
public ResponseEntity<TypedSimpleResponse<Participant>> update(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) {
+ @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) {
return ResponseEntity.ok().body(getSimulationProvider().updateParticipant(body));
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
index 832399660..46495f7c3 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
@@ -234,7 +234,7 @@ class ParticipantSimulatorTest {
String.class, uuid);
checkResponseEntity(response, 200, uuid);
- Map returnValue = coder.decode(response.getBody(), Map.class);
+ Map<?, ?> returnValue = coder.decode(response.getBody(), Map.class);
// Verify the result of GET controlloop elements with what is stored
assertThat(returnValue).isEmpty();
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
index 8ca139bcd..2c9b1ccd2 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.parameters.ParameterGroup;
@@ -57,15 +58,18 @@ public class CommonTestData {
/**
* Converts the contents of a map to a parameter class.
*
+ * @param <T> the specific parameter group type to convert
* @param source property map
* @param clazz class of object to be created from the map
* @return a new object represented by the map
+ * @throws ControlLoopRuntimeException on parameter parsing errors
*/
public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
try {
return coder.convert(source, clazz);
} catch (final CoderException e) {
- throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE,
+ "cannot create " + clazz.getName() + " from map", e);
}
}
@@ -191,14 +195,14 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public ParticipantSimulatorParameters getParticipantParameterGroup(int port) {
try {
return coder.decode(getParticipantParameterGroupAsString(port), ParticipantSimulatorParameters.class);
} catch (CoderException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "cannot read participant parameters", e);
}
}
@@ -207,6 +211,7 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public static String getParticipantParameterGroupAsString(int port) {
@@ -221,7 +226,7 @@ public class CommonTestData {
} catch (IOException e) {
throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
+ e);
}
}