use of org.jboss.pnc.bpm.task.AnalyzeDeliverablesTask in project pnc by project-ncl.
the class RestConnectorRequestSerializationTest method mockAnalyzeDeliverablesTask.
private AnalyzeDeliverablesTask mockAnalyzeDeliverablesTask() {
String url1 = "http://hello.com";
String url2 = "http://world.com";
List<String> urls = new ArrayList<>();
urls.add(url1);
urls.add(url2);
String operationId = Sequence.nextBase32Id();
AnalyzeDeliverablesBpmRequest request = new AnalyzeDeliverablesBpmRequest(operationId, "id", urls);
List<Request.Header> headers = new ArrayList<>();
headers.add(new Request.Header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON));
Request callback = new Request(Request.Method.POST, URI.create("http://mock.com/"), headers);
AnalyzeDeliverablesTask task = new AnalyzeDeliverablesTask(request, callback);
return task;
}
use of org.jboss.pnc.bpm.task.AnalyzeDeliverablesTask in project pnc by project-ncl.
the class RestConnectorRequestSerializationTest method testSerialization.
@Test
public void testSerialization() throws Exception {
// with
AnalyzeDeliverablesTask task = mockAnalyzeDeliverablesTask();
MDC.put(MDCKeys.REQUEST_CONTEXT_KEY, "Hello");
// when
connector.startProcess("analyzer", task, task.getRequest().getOperationId(), "accessToken");
// then
verify(postRequestedFor(urlMatching(".*/analyzer/.*")));
List<LoggedRequest> requests = findAll(postRequestedFor(urlMatching(".*/analyzer/.*")));
assertThat(requests.size()).isOne();
JsonNode body = JsonOutputConverterMapper.getMapper().readTree(requests.get(0).getBodyAsString());
assertThat(body.get("initData")).isNotNull();
assertThat(body.get("initData").get("mdc")).isNotNull();
assertThat(body.get("initData").get("mdc").get(MDCKeys.REQUEST_CONTEXT_KEY)).isNotNull();
assertThat(body.get("initData").get("mdc").get(MDCKeys.REQUEST_CONTEXT_KEY).textValue()).isNotNull().isEqualTo("Hello");
assertThat(body.get("initData").get("task")).isNotNull();
assertThat(body.get("initData").get("task").get("request")).isNotNull();
assertThat(body.get("initData").get("task").get("request").get("urls")).isNotEmpty();
assertThat(body.get("initData").get("task").get("request").get("operationId").toString()).isNotEmpty();
assertThat(body.get("initData").get("task").get("callback")).isNotNull();
}
use of org.jboss.pnc.bpm.task.AnalyzeDeliverablesTask in project pnc by project-ncl.
the class DeliverableAnalyzerManagerImpl method startAnalysis.
private void startAnalysis(String milestoneId, List<String> sourcesLink, Base32LongID operationId) {
Request callback = operationsManager.getOperationCallback(operationId);
String id = operationId.getId();
try (RestConnector restConnector = new RestConnector(bpmConfig)) {
AnalyzeDeliverablesBpmRequest bpmRequest = new AnalyzeDeliverablesBpmRequest(id, milestoneId, sourcesLink);
AnalyzeDeliverablesTask analyzeTask = new AnalyzeDeliverablesTask(bpmRequest, callback);
restConnector.startProcess(bpmConfig.getAnalyzeDeliverablesBpmProcessId(), analyzeTask, id, userService.currentUserToken());
DeliverableAnalysisStatusChangedEvent analysisStatusChanged = DefaultDeliverableAnalysisStatusChangedEvent.started(id, milestoneId, sourcesLink);
analysisStatusChangedEventNotifier.fire(analysisStatusChanged);
} catch (ProcessManagerException e) {
log.error("Error trying to start analysis of deliverables task for milestone: {}", milestoneId, e);
throw new RuntimeException(e);
}
}
Aggregations