This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of signalReceived event (#247)
Related to Activiti/Activiti#2272 Depends on AlfrescoArchive/activiti-api#84 AlfrescoArchive/activiti-cloud-api#65 Activiti/Activiti#2511
- Loading branch information
1 parent
c43fad8
commit c971ba3
Showing
11 changed files
with
447 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...c/main/java/org/activiti/cloud/services/events/listeners/CloudSignalReceivedProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2018 Alfresco, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.activiti.cloud.services.events.listeners; | ||
|
||
import org.activiti.api.process.model.events.BPMNSignalReceivedEvent; | ||
import org.activiti.api.process.runtime.events.listener.BPMNElementEventListener; | ||
import org.activiti.cloud.services.events.converter.ToCloudProcessRuntimeEventConverter; | ||
|
||
public class CloudSignalReceivedProducer implements BPMNElementEventListener<BPMNSignalReceivedEvent> { | ||
|
||
private final ToCloudProcessRuntimeEventConverter eventConverter; | ||
private final ProcessEngineEventsAggregator eventsAggregator; | ||
|
||
public CloudSignalReceivedProducer(ToCloudProcessRuntimeEventConverter eventConverter, | ||
ProcessEngineEventsAggregator eventsAggregator) { | ||
this.eventConverter = eventConverter; | ||
this.eventsAggregator = eventsAggregator; | ||
} | ||
|
||
@Override | ||
public void onEvent(BPMNSignalReceivedEvent event) { | ||
eventsAggregator.add(eventConverter.from(event)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...st/java/org/activiti/cloud/services/events/listeners/CloudSignalReceivedProducerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019 Alfresco, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.activiti.cloud.services.events.listeners; | ||
|
||
import org.activiti.api.runtime.event.impl.BPMNSignalReceivedEventImpl; | ||
import org.activiti.api.runtime.model.impl.BPMNSignalImpl; | ||
import org.activiti.cloud.api.process.model.impl.events.CloudBPMNSignalReceivedEventImpl; | ||
import org.activiti.cloud.services.events.converter.ToCloudProcessRuntimeEventConverter; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
|
||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.MockitoAnnotations.initMocks; | ||
|
||
public class CloudSignalReceivedProducerTest { | ||
|
||
@InjectMocks | ||
private CloudSignalReceivedProducer cloudSignalReceivedProducer; | ||
|
||
@Mock | ||
private ToCloudProcessRuntimeEventConverter eventConverter; | ||
@Mock | ||
private ProcessEngineEventsAggregator eventsAggregator; | ||
|
||
@Before | ||
public void setUp() { | ||
initMocks(this); | ||
} | ||
|
||
@Test | ||
public void onEventShouldConvertEventToCloudEventAndAddToAggregator() { | ||
//given | ||
BPMNSignalReceivedEventImpl event = new BPMNSignalReceivedEventImpl(new BPMNSignalImpl()); | ||
CloudBPMNSignalReceivedEventImpl cloudEvent = new CloudBPMNSignalReceivedEventImpl(); | ||
given(eventConverter.from(event)).willReturn(cloudEvent); | ||
|
||
//when | ||
cloudSignalReceivedProducer.onEvent(event); | ||
|
||
//then | ||
verify(eventsAggregator).add(cloudEvent); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...time-bundle/src/test/java/org/activiti/cloud/starter/tests/helper/SignalRestTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2019 Alfresco, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.activiti.cloud.starter.tests.helper; | ||
|
||
import org.activiti.api.process.model.payloads.SignalPayload; | ||
import org.springframework.boot.test.context.TestComponent; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.core.ParameterizedTypeReference; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import static org.activiti.cloud.starter.tests.helper.ProcessInstanceRestTemplate.PROCESS_INSTANCES_RELATIVE_URL; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@TestComponent | ||
public class SignalRestTemplate { | ||
|
||
private TestRestTemplate testRestTemplate; | ||
|
||
public SignalRestTemplate(TestRestTemplate testRestTemplate) { | ||
this.testRestTemplate = testRestTemplate; | ||
} | ||
|
||
public void signal(SignalPayload signalProcessInstancesCmd) { | ||
ResponseEntity<Void> responseEntity = testRestTemplate.exchange(PROCESS_INSTANCES_RELATIVE_URL + "/signal", | ||
HttpMethod.POST, | ||
new HttpEntity<>(signalProcessInstancesCmd), | ||
new ParameterizedTypeReference<Void>() { | ||
}); | ||
|
||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
} | ||
|
||
} |
Oops, something went wrong.