Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
ICS reading auth token from file
[nonrtric.git]
/
information-coordinator-service
/
src
/
test
/
java
/
org
/
oransc
/
ics
/
controller
/
ProducerSimulatorController.java
diff --git
a/information-coordinator-service/src/test/java/org/oransc/ics/controller/ProducerSimulatorController.java
b/information-coordinator-service/src/test/java/org/oransc/ics/controller/ProducerSimulatorController.java
index
55d32b0
..
a5ddc49
100644
(file)
--- a/
information-coordinator-service/src/test/java/org/oransc/ics/controller/ProducerSimulatorController.java
+++ b/
information-coordinator-service/src/test/java/org/oransc/ics/controller/ProducerSimulatorController.java
@@
-31,11
+31,13
@@
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import lombok.Getter;
import org.oransc.ics.controllers.ErrorResponse;
import org.oransc.ics.controllers.VoidResponse;
import lombok.Getter;
import org.oransc.ics.controllers.ErrorResponse;
import org.oransc.ics.controllers.VoidResponse;
+import org.oransc.ics.controllers.r1consumer.ConsumerConsts;
import org.oransc.ics.controllers.r1producer.ProducerConsts;
import org.oransc.ics.controllers.r1producer.ProducerJobInfo;
import org.slf4j.Logger;
import org.oransc.ics.controllers.r1producer.ProducerConsts;
import org.oransc.ics.controllers.r1producer.ProducerJobInfo;
import org.slf4j.Logger;
@@
-48,24
+50,27
@@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
@RestController("ProducerSimulatorController")
import org.springframework.web.bind.annotation.RestController;
@RestController("ProducerSimulatorController")
-@Tag(name = ProducerConsts.PRODUCER_API_CALLBACKS_NAME)
+@Tag(name = ProducerConsts.PRODUCER_API_CALLBACKS_NAME
, description = ProducerConsts.PRODUCER_API_CALLBACKS_DESCRIPTION
)
public class ProducerSimulatorController {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public class ProducerSimulatorController {
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static final String JOB_URL = "/example
_dataproducer/info_
job";
- public static final String JOB_ERROR_URL = "/example
_dataproducer/info_job_
error";
+ public static final String JOB_URL = "/example
-dataproducer/info-
job";
+ public static final String JOB_ERROR_URL = "/example
-dataproducer/info-job-
error";
- public static final String SUPERVISION_URL = "/example
_dataproducer/health_
check";
- public static final String SUPERVISION_ERROR_URL = "/example
_dataproducer/health_check_
error";
+ public static final String SUPERVISION_URL = "/example
-dataproducer/health-
check";
+ public static final String SUPERVISION_ERROR_URL = "/example
-dataproducer/health-check-
error";
public static class TestResults {
public List<ProducerJobInfo> jobsStarted = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
public List<String> jobsStopped = Collections.synchronizedList(new ArrayList<String>());
public static class TestResults {
public List<ProducerJobInfo> jobsStarted = Collections.synchronizedList(new ArrayList<ProducerJobInfo>());
public List<String> jobsStopped = Collections.synchronizedList(new ArrayList<String>());
+ public List<Map<String, String>> receivedHeaders =
+ Collections.synchronizedList(new ArrayList<Map<String, String>>());
public int noOfRejectedCreate = 0;
public int noOfRejectedDelete = 0;
public boolean errorFound = false;
public int noOfRejectedCreate = 0;
public int noOfRejectedDelete = 0;
public boolean errorFound = false;
@@
-76,6
+81,7
@@
public class ProducerSimulatorController {
public void reset() {
jobsStarted.clear();
jobsStopped.clear();
public void reset() {
jobsStarted.clear();
jobsStopped.clear();
+ receivedHeaders.clear();
this.errorFound = false;
this.noOfRejectedCreate = 0;
this.noOfRejectedDelete = 0;
this.errorFound = false;
this.noOfRejectedCreate = 0;
this.noOfRejectedDelete = 0;
@@
-97,9
+103,12
@@
public class ProducerSimulatorController {
content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
})
public ResponseEntity<Object> jobCreatedCallback( //
content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
})
public ResponseEntity<Object> jobCreatedCallback( //
+ @RequestHeader Map<String, String> headers, //
@RequestBody ProducerJobInfo request) {
try {
@RequestBody ProducerJobInfo request) {
try {
+ logHeaders(headers);
this.testResults.jobsStarted.add(request);
this.testResults.jobsStarted.add(request);
+ this.testResults.receivedHeaders.add(headers);
logger.info("Job started callback {}", request.id);
if (request.id == null) {
throw new NullPointerException("Illegal argument");
logger.info("Job started callback {}", request.id);
if (request.id == null) {
throw new NullPointerException("Illegal argument");
@@
-123,10
+132,12
@@
public class ProducerSimulatorController {
content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
})
public ResponseEntity<Object> jobDeletedCallback( //
content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
})
public ResponseEntity<Object> jobDeletedCallback( //
- @
PathVariable("infoJobId"
) String infoJobId) {
+ @
RequestHeader Map<String, String> headers, @PathVariable(ConsumerConsts.INFO_JOB_ID_PATH
) String infoJobId) {
try {
try {
+ logHeaders(headers);
logger.info("Job deleted callback {}", infoJobId);
this.testResults.jobsStopped.add(infoJobId);
logger.info("Job deleted callback {}", infoJobId);
this.testResults.jobsStopped.add(infoJobId);
+ this.testResults.receivedHeaders.add(headers);
return new ResponseEntity<>(HttpStatus.OK);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
return new ResponseEntity<>(HttpStatus.OK);
} catch (Exception e) {
return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
@@
-159,7
+170,7
@@
public class ProducerSimulatorController {
content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
})
public ResponseEntity<Object> jobDeletedCallbackReturnError( //
content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
})
public ResponseEntity<Object> jobDeletedCallbackReturnError( //
- @PathVariable(
"infoJobId"
) String infoJobId) {
+ @PathVariable(
ConsumerConsts.INFO_JOB_ID_PATH
) String infoJobId) {
logger.info("Job created (returning error) callback {}", infoJobId);
this.testResults.noOfRejectedDelete += 1;
return ErrorResponse.create("Producer returns error on delete job", HttpStatus.NOT_FOUND);
logger.info("Job created (returning error) callback {}", infoJobId);
this.testResults.noOfRejectedDelete += 1;
return ErrorResponse.create("Producer returns error on delete job", HttpStatus.NOT_FOUND);
@@
-178,7
+189,7
@@
public class ProducerSimulatorController {
})
public ResponseEntity<Object> producerSupervision() {
logger.info("Producer supervision");
})
public ResponseEntity<Object> producerSupervision() {
logger.info("Producer supervision");
- return new ResponseEntity<>(HttpStatus.OK);
+ return new ResponseEntity<>(
"Hunky dory",
HttpStatus.OK);
}
@GetMapping(path = SUPERVISION_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
}
@GetMapping(path = SUPERVISION_ERROR_URL, produces = MediaType.APPLICATION_JSON_VALUE)
@@
-195,4
+206,10
@@
public class ProducerSimulatorController {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
+ private void logHeaders(Map<String, String> headers) {
+ logger.debug("Header begin");
+ headers.forEach((key, value) -> logger.debug(" key: {}, value: {}", key, value));
+ logger.debug("Header end");
+ }
+
}
}