Remove allure (phase2) (#2483)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -23,9 +23,6 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystem;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
||||
@@ -65,8 +62,10 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@ActiveProfiles({ "test" })
|
||||
@Feature("Component Tests - Device Management Federation API")
|
||||
@Story("AmqpMessage Dispatcher Service Test")
|
||||
/**
|
||||
* Feature: Component Tests - Device Management Federation API<br/>
|
||||
* Story: AmqpMessage Dispatcher Service Test
|
||||
*/
|
||||
@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||
class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
|
||||
@@ -116,9 +115,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
return argumentCaptor.getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that download and install event with 3 software modules and no artifacts works")
|
||||
void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
|
||||
/**
|
||||
* Verifies that download and install event with 3 software modules and no artifacts works
|
||||
*/
|
||||
@Test void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
|
||||
final DistributionSet createDistributionSet = testdataFactory
|
||||
.createDistributionSet(UUID.randomUUID().toString());
|
||||
testdataFactory.addSoftwareModuleMetadata(createDistributionSet);
|
||||
@@ -155,9 +155,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that download and install event with software modules and artifacts works")
|
||||
void testSendDownloadRequest() {
|
||||
/**
|
||||
* Verifies that download and install event with software modules and artifacts works
|
||||
*/
|
||||
@Test void testSendDownloadRequest() {
|
||||
DistributionSet dsA = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
|
||||
SoftwareModule module = dsA.getModules().iterator().next();
|
||||
final List<AbstractDbArtifact> receivedList = new ArrayList<>();
|
||||
@@ -206,9 +207,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that sending update controller attributes event works.")
|
||||
void sendUpdateAttributesRequest() {
|
||||
/**
|
||||
* Verifies that sending update controller attributes event works.
|
||||
*/
|
||||
@Test void sendUpdateAttributesRequest() {
|
||||
final String amqpUri = "amqp://anyhost";
|
||||
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT,
|
||||
1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId());
|
||||
@@ -219,9 +221,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
assertUpdateAttributesMessage(sendMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that send cancel event works")
|
||||
void testSendCancelRequest() {
|
||||
/**
|
||||
* Verifies that send cancel event works
|
||||
*/
|
||||
@Test void testSendCancelRequest() {
|
||||
final Action action = mock(Action.class);
|
||||
when(action.getId()).thenReturn(1L);
|
||||
when(action.getTenant()).thenReturn(TENANT);
|
||||
@@ -235,9 +238,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that sending a delete message when receiving a delete event works.")
|
||||
void sendDeleteRequest() {
|
||||
/**
|
||||
* Verifies that sending a delete message when receiving a delete event works.
|
||||
*/
|
||||
@Test void sendDeleteRequest() {
|
||||
|
||||
// setup
|
||||
final String amqpUri = "amqp://anyhost";
|
||||
@@ -252,9 +256,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
assertDeleteMessage(sendMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that a delete message is not send if the address is not an amqp address.")
|
||||
void sendDeleteRequestWithNoAmqpAddress() {
|
||||
/**
|
||||
* Verifies that a delete message is not send if the address is not an amqp address.
|
||||
*/
|
||||
@Test void sendDeleteRequestWithNoAmqpAddress() {
|
||||
|
||||
// setup
|
||||
final String noAmqpUri = "http://anyhost";
|
||||
@@ -268,9 +273,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
||||
Mockito.verifyNoInteractions(senderService);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that a delete message is not send if the address is null.")
|
||||
void sendDeleteRequestWithNullAddress() {
|
||||
/**
|
||||
* Verifies that a delete message is not send if the address is null.
|
||||
*/
|
||||
@Test void sendDeleteRequestWithNullAddress() {
|
||||
|
||||
// setup
|
||||
final String noAmqpUri = null;
|
||||
|
||||
@@ -26,10 +26,6 @@ import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
|
||||
@@ -76,8 +72,10 @@ import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@Feature("Component Tests - Device Management Federation API")
|
||||
@Story("AmqpMessage Handler Service Test")
|
||||
/**
|
||||
* Feature: Component Tests - Device Management Federation API<br/>
|
||||
* Story: AmqpMessage Handler Service Test
|
||||
*/
|
||||
class AmqpMessageHandlerServiceTest {
|
||||
|
||||
private static final String FAIL_MESSAGE_AMQP_REJECT_REASON = AmqpRejectAndDontRequeueException.class
|
||||
@@ -144,9 +142,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
confirmationManagementMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests not allowed content-type in message")
|
||||
void wrongContentType() {
|
||||
/**
|
||||
* Tests not allowed content-type in message
|
||||
*/
|
||||
@Test void wrongContentType() {
|
||||
final MessageProperties messageProperties = new MessageProperties();
|
||||
messageProperties.setContentType("xml");
|
||||
final Message message = new Message(new byte[0], messageProperties);
|
||||
@@ -157,9 +156,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void createThing() {
|
||||
/**
|
||||
* Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void createThing() {
|
||||
final String knownThingId = "1";
|
||||
|
||||
processThingCreatedMessage(knownThingId, null);
|
||||
@@ -168,9 +168,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertReplyToCapturedField("MyTest");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a target/thing with specified name by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void createThingWithName() {
|
||||
/**
|
||||
* Tests the creation of a target/thing with specified name by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void createThingWithName() {
|
||||
final String knownThingId = "2";
|
||||
final String knownThingName = "NonDefaultTargetName";
|
||||
|
||||
@@ -183,9 +184,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThingNameCapturedField(knownThingName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a target/thing with specified type name by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void createThingWithType() {
|
||||
/**
|
||||
* Tests the creation of a target/thing with specified type name by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void createThingWithType() {
|
||||
final String knownThingId = "2";
|
||||
final String knownThingTypeName = "TargetTypeName";
|
||||
|
||||
@@ -198,9 +200,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThingTypeCapturedField(knownThingTypeName);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests not allowed body in message")
|
||||
void createThingWithWrongBody() {
|
||||
/**
|
||||
* Tests not allowed body in message
|
||||
*/
|
||||
@Test void createThingWithWrongBody() {
|
||||
final Message message = createMessage("Not allowed Body".getBytes(), getThingCreatedMessageProperties("3"));
|
||||
final String type = MessageType.THING_CREATED.name();
|
||||
assertThatExceptionOfType(MessageConversionException.class)
|
||||
@@ -208,9 +211,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a target/thing with specified attributes by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void createThingWithAttributes() {
|
||||
/**
|
||||
* Tests the creation of a target/thing with specified attributes by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void createThingWithAttributes() {
|
||||
final String knownThingId = "4";
|
||||
|
||||
final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate();
|
||||
@@ -224,9 +228,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThingAttributesCapturedField(attributeUpdate.getAttributes());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a target/thing with specified name and attributes by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void createThingWithNameAndAttributes() {
|
||||
/**
|
||||
* Tests the creation of a target/thing with specified name and attributes by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void createThingWithNameAndAttributes() {
|
||||
final String knownThingId = "5";
|
||||
final String knownThingName = "NonDefaultTargetName";
|
||||
|
||||
@@ -242,9 +247,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThingAttributesModeCapturedField(UpdateMode.REPLACE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the target attribute update by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void updateAttributes() {
|
||||
/**
|
||||
* Tests the target attribute update by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void updateAttributes() {
|
||||
final String knownThingId = "1";
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
|
||||
@@ -262,9 +268,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThingAttributesCapturedField(attributeUpdate.getAttributes());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the update mode is retrieved from the UPDATE_ATTRIBUTES message and passed to the controller management.")
|
||||
void attributeUpdateModes() {
|
||||
/**
|
||||
* Verifies that the update mode is retrieved from the UPDATE_ATTRIBUTES message and passed to the controller management.
|
||||
*/
|
||||
@Test void attributeUpdateModes() {
|
||||
final String knownThingId = "1";
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
|
||||
@@ -312,9 +319,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
Map.of("testKey1", "testValue1", "testKey2", "testValue2"), mode);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a thing without a 'reply to' header in message.")
|
||||
void createThingWithoutReplyTo() {
|
||||
/**
|
||||
* Tests the creation of a thing without a 'reply to' header in message.
|
||||
*/
|
||||
@Test void createThingWithoutReplyTo() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null);
|
||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
|
||||
final Message message = createMessage("", messageProperties);
|
||||
@@ -324,9 +332,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.")
|
||||
void createThingWithoutID() {
|
||||
/**
|
||||
* Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.
|
||||
*/
|
||||
@Test void createThingWithoutID() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
||||
final Message message = createMessage(new byte[0], messageProperties);
|
||||
final String type = MessageType.THING_CREATED.name();
|
||||
@@ -335,9 +344,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.")
|
||||
void unknownMessageType() {
|
||||
/**
|
||||
* Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.
|
||||
*/
|
||||
@Test void unknownMessageType() {
|
||||
final String type = "bumlux";
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, "");
|
||||
@@ -348,9 +358,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests a invalid message without event topic")
|
||||
void invalidEventTopic() {
|
||||
/**
|
||||
* Tests a invalid message without event topic
|
||||
*/
|
||||
@Test void invalidEventTopic() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
final Message message = new Message(new byte[0], messageProperties);
|
||||
|
||||
@@ -370,9 +381,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the update of an action of a target without a exist action id")
|
||||
void updateActionStatusWithoutActionId() {
|
||||
/**
|
||||
* Tests the update of an action of a target without a exist action id
|
||||
*/
|
||||
@Test void updateActionStatusWithoutActionId() {
|
||||
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty());
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||
@@ -384,9 +396,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the update of an action of a target without a exist action id")
|
||||
void updateActionStatusWithoutExistActionId() {
|
||||
/**
|
||||
* Tests the update of an action of a target without a exist action id
|
||||
*/
|
||||
@Test void updateActionStatusWithoutExistActionId() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty());
|
||||
@@ -400,9 +413,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests that messages which cause quota violations are not re-added to message queue so they would block other communication.")
|
||||
void quotaExceeded() {
|
||||
/**
|
||||
* Tests that messages which cause quota violations are not re-added to message queue so they would block other communication.
|
||||
*/
|
||||
@Test void quotaExceeded() {
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||
|
||||
@@ -425,9 +439,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test next update is provided on finished action")
|
||||
void lookupNextUpdateActionAfterFinished() throws IllegalAccessException {
|
||||
/**
|
||||
* Test next update is provided on finished action
|
||||
*/
|
||||
@Test void lookupNextUpdateActionAfterFinished() throws IllegalAccessException {
|
||||
|
||||
// Mock
|
||||
final Action action = createActionWithTarget(22L);
|
||||
@@ -462,9 +477,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThat(actionProperties.getId()).as("event has wrong action id").isEqualTo(22L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test feedback code is persisted in messages when provided with DmfActionUpdateStatus")
|
||||
void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
|
||||
/**
|
||||
* Test feedback code is persisted in messages when provided with DmfActionUpdateStatus
|
||||
*/
|
||||
@Test void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
|
||||
// Mock
|
||||
final Action action = createActionWithTarget(22L);
|
||||
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
|
||||
@@ -496,9 +512,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.contains("Device reported status code: 12");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the deletion of a target/thing, requested by the target itself.")
|
||||
void deleteThing() {
|
||||
/**
|
||||
* Tests the deletion of a target/thing, requested by the target itself.
|
||||
*/
|
||||
@Test void deleteThing() {
|
||||
// prepare valid message
|
||||
final String knownThingId = "1";
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED);
|
||||
@@ -512,9 +529,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
verify(controllerManagementMock).deleteExistingTarget(knownThingId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the deletion of a target/thing with missing thingId")
|
||||
void deleteThingWithoutThingId() {
|
||||
/**
|
||||
* Tests the deletion of a target/thing with missing thingId
|
||||
*/
|
||||
@Test void deleteThingWithoutThingId() {
|
||||
// prepare invalid message
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED);
|
||||
final Message message = createMessage(new byte[0], messageProperties);
|
||||
@@ -525,9 +543,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests activating auto-confirmation on a target.")
|
||||
void setAutoConfirmationStateActive() {
|
||||
/**
|
||||
* Tests activating auto-confirmation on a target.
|
||||
*/
|
||||
@Test void setAutoConfirmationStateActive() {
|
||||
final String knownThingId = "1";
|
||||
final String initiator = "iAmTheInitiator";
|
||||
final String remark = "remarkForTesting";
|
||||
@@ -551,9 +570,10 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertRemarkCapturedField(remark);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests deactivating auto-confirmation on a target.")
|
||||
void setAutoConfirmationStateDeactivated() {
|
||||
/**
|
||||
* Tests deactivating auto-confirmation on a target.
|
||||
*/
|
||||
@Test void setAutoConfirmationStateDeactivated() {
|
||||
final String knownThingId = "1";
|
||||
|
||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||
@@ -571,7 +591,6 @@ class AmqpMessageHandlerServiceTest {
|
||||
assertThingIdCapturedField(knownThingId);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void processThingCreatedMessage(final String thingId, final DmfCreateThing payload) {
|
||||
final MessageProperties messageProperties = getThingCreatedMessageProperties(thingId);
|
||||
final Message message = createMessage(payload != null ? payload : new byte[0], messageProperties);
|
||||
@@ -594,42 +613,34 @@ class AmqpMessageHandlerServiceTest {
|
||||
amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, VIRTUAL_HOST);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertThingIdCapturedField(final String thingId) {
|
||||
assertThat(targetIdCaptor.getValue()).as("Thing id is wrong").isEqualTo(thingId);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertReplyToCapturedField(final String replyTo) {
|
||||
assertThat(uriCaptor.getValue()).as("Uri is not right").hasToString("amqp://" + VIRTUAL_HOST + "/" + replyTo);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertInitiatorCapturedField(final String initiator) {
|
||||
assertThat(initiatorCaptor.getValue()).as("Initiator is wrong").isEqualTo(initiator);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertRemarkCapturedField(final String remark) {
|
||||
assertThat(remarkCaptor.getValue()).as("Remark is wrong").isEqualTo(remark);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertThingNameCapturedField(final String thingName) {
|
||||
assertThat(targetNameCaptor.getValue()).as("Thing name is wrong").isEqualTo(thingName);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertThingTypeCapturedField(final String thingType) {
|
||||
assertThat(targetTypeNameCaptor.getValue()).as("Thing type is wrong").isEqualTo(thingType);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertThingAttributesCapturedField(final Map<String, String> attributes) {
|
||||
assertThat(attributesCaptor.getValue()).as("Attributes is not right").isEqualTo(attributes);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void assertThingAttributesModeCapturedField(final UpdateMode attributesUpdateMode) {
|
||||
assertThat(modeCaptor.getValue()).as("Attributes update mode is not right").isEqualTo(attributesUpdateMode);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
@@ -35,8 +32,10 @@ import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@Feature("Component Tests - Device Management Federation API")
|
||||
@Story("Base Amqp Service Test")
|
||||
/**
|
||||
* Feature: Component Tests - Device Management Federation API<br/>
|
||||
* Story: Base Amqp Service Test
|
||||
*/
|
||||
class BaseAmqpServiceTest {
|
||||
|
||||
@Mock
|
||||
@@ -49,9 +48,10 @@ class BaseAmqpServiceTest {
|
||||
baseAmqpService = new BaseAmqpService(rabbitTemplate);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that the message conversion works")
|
||||
void convertMessageTest() {
|
||||
/**
|
||||
* Verify that the message conversion works
|
||||
*/
|
||||
@Test void convertMessageTest() {
|
||||
final DmfActionUpdateStatus actionUpdateStatus = createActionStatus();
|
||||
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());
|
||||
|
||||
@@ -60,18 +60,20 @@ class BaseAmqpServiceTest {
|
||||
assertThat(convertedActionUpdateStatus).usingRecursiveComparison().isEqualTo(actionUpdateStatus);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests invalid null message content")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
/**
|
||||
* Tests invalid null message content
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
void convertMessageWithNullContent() {
|
||||
assertThatExceptionOfType(IllegalArgumentException.class)
|
||||
.as("Expected IllegalArgumentException for invalid (null) JSON")
|
||||
.isThrownBy(() -> createMessage(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests invalid empty message content")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
/**
|
||||
* Tests invalid empty message content
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
void updateActionStatusWithEmptyContent() {
|
||||
final Message message = createMessage("".getBytes());
|
||||
assertThatExceptionOfType(MessageConversionException.class)
|
||||
@@ -79,9 +81,10 @@ class BaseAmqpServiceTest {
|
||||
.isThrownBy(() -> baseAmqpService.convertMessage(message, DmfActionUpdateStatus.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests invalid json message content")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
/**
|
||||
* Tests invalid json message content
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
void updateActionStatusWithInvalidJsonContent() {
|
||||
final Message message = createMessage("Invalid Json".getBytes());
|
||||
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());
|
||||
|
||||
@@ -13,45 +13,48 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
|
||||
import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
|
||||
@Feature("Unit Tests - Requeue Exception Strategy")
|
||||
@Story("Requeue Exception Strategy")
|
||||
/**
|
||||
* Feature: Unit Tests - Requeue Exception Strategy<br/>
|
||||
* Story: Requeue Exception Strategy
|
||||
*/
|
||||
class RequestExceptionStrategyTest {
|
||||
|
||||
private final FatalExceptionStrategy requeueExceptionStrategy = new RequeueExceptionStrategy(
|
||||
List.of(new RequeueExceptionStrategy.TypeBasedFatalExceptionStrategy(
|
||||
IllegalArgumentException.class, IndexOutOfBoundsException.class)), null);
|
||||
|
||||
@Test
|
||||
@Description("Verifies that default handler is used if no handlers are defined for the specific exception.")
|
||||
void verifyDefaultFatal() {
|
||||
/**
|
||||
* Verifies that default handler is used if no handlers are defined for the specific exception.
|
||||
*/
|
||||
@Test void verifyDefaultFatal() {
|
||||
assertThat(requeueExceptionStrategy.isFatal(new MessageConversionException("t"))).as("Non Fatal error").isTrue();
|
||||
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new MessageConversionException("t")))).as("Non Fatal error").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies additional fatal exception types are fatal.")
|
||||
void verifyAdditionalFatal() {
|
||||
/**
|
||||
* Verifies additional fatal exception types are fatal.
|
||||
*/
|
||||
@Test void verifyAdditionalFatal() {
|
||||
assertThat(requeueExceptionStrategy.isFatal(new IllegalArgumentException())).isTrue();
|
||||
assertThat(requeueExceptionStrategy.isFatal(new IndexOutOfBoundsException())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies additional fatal exception types are fatal.")
|
||||
void verifyAdditionalWrappedFatal() {
|
||||
/**
|
||||
* Verifies additional fatal exception types are fatal.
|
||||
*/
|
||||
@Test void verifyAdditionalWrappedFatal() {
|
||||
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IllegalArgumentException()))).isTrue();
|
||||
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IndexOutOfBoundsException()))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that default handler is used if no handlers are defined for the specific exception.")
|
||||
void verifyNonFatal() {
|
||||
/**
|
||||
* Verifies that default handler is used if no handlers are defined for the specific exception.
|
||||
*/
|
||||
@Test void verifyNonFatal() {
|
||||
assertThat(requeueExceptionStrategy.isFatal(new NullPointerException())).isFalse();
|
||||
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new NullPointerException()))).isFalse();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.cronutils.utils.StringUtils;
|
||||
import io.qameta.allure.Step;
|
||||
import org.assertj.core.api.HamcrestCondition;
|
||||
import org.eclipse.hawkbit.amqp.DmfApiConfiguration;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
|
||||
@@ -254,7 +253,6 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
|
||||
return replyMessage;
|
||||
}
|
||||
|
||||
@Step
|
||||
protected void registerAndAssertTargetWithExistingTenant(final String controllerId) {
|
||||
registerAndAssertTargetWithExistingTenant(controllerId, 1);
|
||||
}
|
||||
@@ -372,7 +370,6 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
|
||||
|
||||
}
|
||||
|
||||
@Step
|
||||
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
|
||||
waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId));
|
||||
|
||||
@@ -393,7 +390,6 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
|
||||
return AmqpSettings.DMF_EXCHANGE;
|
||||
}
|
||||
|
||||
@Step
|
||||
protected DistributionSet createTargetAndDistributionSetAndAssign(final String controllerId, final Action.ActionType actionType) {
|
||||
registerAndAssertTargetWithExistingTenant(controllerId);
|
||||
|
||||
|
||||
@@ -30,9 +30,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
|
||||
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
|
||||
@@ -83,15 +80,18 @@ import org.junit.jupiter.params.provider.EnumSource;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.amqp.core.Message;
|
||||
|
||||
@Feature("Component Tests - Device Management Federation API")
|
||||
@Story("Amqp Message Dispatcher Service")
|
||||
/**
|
||||
* Feature: Component Tests - Device Management Federation API<br/>
|
||||
* Story: Amqp Message Dispatcher Service
|
||||
*/
|
||||
class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
|
||||
|
||||
private static final String TARGET_PREFIX = "Dmf_disp_";
|
||||
|
||||
@Test
|
||||
@Description("Verify that a distribution assignment send a download and install message.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that a distribution assignment send a download and install message.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -109,9 +109,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertDownloadAndInstallMessage(getDistributionSet().getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -134,9 +135,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertDownloadMessage(distributionSet.getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -159,9 +161,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertDownloadAndInstallMessage(distributionSet.getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
|
||||
@@ -205,9 +208,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertDownloadAndInstallMessage(distributionSet2.getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("If multi assignment is enabled multi-action messages are sent.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* If multi assignment is enabled multi-action messages are sent.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = MultiActionAssignEvent.class, count = 2),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
|
||||
@@ -237,9 +241,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install, action2Install));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify payload of multi action messages.")
|
||||
void assertMultiActionMessagePayloads() {
|
||||
/**
|
||||
* Verify payload of multi action messages.
|
||||
*/
|
||||
@Test void assertMultiActionMessagePayloads() {
|
||||
final int expectedWeightIfNotSet = 1000;
|
||||
final int weight1 = 600;
|
||||
final String controllerId = UUID.randomUUID().toString();
|
||||
@@ -286,9 +291,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handle cancelation process of an action in multi assignment mode.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Handle cancelation process of an action in multi assignment mode.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 2),
|
||||
@Expect(type = TargetPollEvent.class, count = 1),
|
||||
@@ -325,9 +331,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Handle finishing an action in multi assignment mode.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Handle finishing an action in multi assignment mode.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = MultiActionAssignEvent.class, count = 2),
|
||||
@Expect(type = TargetAttributesRequestedEvent.class, count = 1),
|
||||
@@ -358,9 +365,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("If multi assignment is enabled assigning a DS multiple times creates a new action every time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* If multi assignment is enabled assigning a DS multiple times creates a new action every time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = MultiActionAssignEvent.class, count = 2),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
|
||||
@@ -390,9 +398,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install, action2Install));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = MultiActionAssignEvent.class, count = 2),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
|
||||
@@ -428,9 +437,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertLatestMultiActionMessageContainsInstallMessages(controllerId, Arrays.asList(smIds, smIds));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = MultiActionAssignEvent.class, count = 3),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 3),
|
||||
@@ -479,9 +489,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertLatestMultiActionMessageContainsInstallMessages(controllerId, Collections.singletonList(smIds1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a cancel assignment send a cancel message.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that a cancel assignment send a cancel message.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
|
||||
@@ -503,9 +514,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertCancelActionMessage(actionId, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that when a target is deleted a target delete message is send.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that when a target is deleted a target delete message is send.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 1),
|
||||
@Expect(type = TargetDeletedEvent.class, count = 1) })
|
||||
@@ -517,9 +529,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertDeleteMessage(controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that attribute update is requested after device successfully closed software update.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that attribute update is requested after device successfully closed software update.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 2),
|
||||
@@ -546,9 +559,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertRequestAttributesUpdateMessage(controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -580,15 +594,17 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertThat(assignedDistributionSet.getId()).isEqualTo(distributionSet.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify payload of batch assignment download and install message.")
|
||||
void assertBatchAssignmentsDownloadAndInstall() {
|
||||
/**
|
||||
* Verify payload of batch assignment download and install message.
|
||||
*/
|
||||
@Test void assertBatchAssignmentsDownloadAndInstall() {
|
||||
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD_AND_INSTALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify payload of batch assignments download only message.")
|
||||
void assertBatchAssignmentsDownloadOnly() {
|
||||
/**
|
||||
* Verify payload of batch assignments download only message.
|
||||
*/
|
||||
@Test void assertBatchAssignmentsDownloadOnly() {
|
||||
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD);
|
||||
}
|
||||
|
||||
@@ -616,9 +632,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertThat(replyToListener.getLatestEventMessage(eventTopic)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that batch and multi-assignments can't be activated at the same time.")
|
||||
void assertBatchAndMultiAssignmentsNotCompatible() {
|
||||
/**
|
||||
* Verify that batch and multi-assignments can't be activated at the same time.
|
||||
*/
|
||||
@Test void assertBatchAndMultiAssignmentsNotCompatible() {
|
||||
enableBatchAssignments();
|
||||
assertThatExceptionOfType(TenantConfigurationValueChangeNotAllowedException.class)
|
||||
.isThrownBy(() -> enableMultiAssignments());
|
||||
@@ -629,9 +646,11 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
.isThrownBy(() -> enableBatchAssignments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify payload of batch assignments.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@EnumSource(names = { "BATCH_DOWNLOAD_AND_INSTALL", "BATCH_DOWNLOAD" })
|
||||
@Description("Verify payload of batch assignments.")
|
||||
@ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 3),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@@ -672,9 +691,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
|
||||
assertDmfBatchDownloadAndUpdateRequest(batchRequest, ds.getModules(), targets);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a distribution assignment send a confirm message.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that a distribution assignment send a confirm message.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
|
||||
@@ -27,10 +27,6 @@ import java.util.UUID;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.eclipse.hawkbit.amqp.AmqpMessageHandlerService;
|
||||
import org.eclipse.hawkbit.amqp.AmqpProperties;
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
|
||||
@@ -78,8 +74,10 @@ import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Feature("Component Tests - Device Management Federation API")
|
||||
@Story("Amqp Message Handler Service")
|
||||
/**
|
||||
* Feature: Component Tests - Device Management Federation API<br/>
|
||||
* Story: Amqp Message Handler Service
|
||||
*/
|
||||
class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
|
||||
|
||||
static final String DMF_REGISTER_TEST_CONTROLLER_ID = "Dmf_hand_registerTargets_1";
|
||||
@@ -93,9 +91,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
@Autowired
|
||||
private AmqpMessageHandlerService amqpMessageHandlerService;
|
||||
|
||||
@Test
|
||||
@Description("Tests DMF PING request and expected response.")
|
||||
void pingDmfInterface() {
|
||||
/**
|
||||
* Tests DMF PING request and expected response.
|
||||
*/
|
||||
@Test void pingDmfInterface() {
|
||||
final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST);
|
||||
getDmfClient().send(pingMessage);
|
||||
|
||||
@@ -104,9 +103,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests register target")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests register target
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 2),
|
||||
@Expect(type = TargetPollEvent.class, count = 3) })
|
||||
void registerTargets() {
|
||||
@@ -120,9 +120,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests register target with name")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests register target with name
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
@@ -138,9 +139,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests register target with attributes")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests register target with attributes
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 2),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
@@ -159,9 +161,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests register target with name and attributes")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests register target with name and attributes
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 3),
|
||||
@Expect(type = TargetPollEvent.class, count = 2) })
|
||||
@@ -183,9 +186,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
/**
|
||||
* Tests register invalid target with empty controller id.
|
||||
*/
|
||||
@ValueSource(strings = { "", "Invalid Invalid" })
|
||||
@NullSource
|
||||
@Description("Tests register invalid target with empty controller id.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void shouldNotRegisterTargetsWithInvalidControllerIds(String controllerId) {
|
||||
createAndSendThingCreated(controllerId);
|
||||
@@ -193,18 +198,20 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests register invalid target with too long controller id")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests register invalid target with too long controller id
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void registerInvalidTargetWithTooLongControllerId() {
|
||||
createAndSendThingCreated(randomString(Target.CONTROLLER_ID_MAX_SIZE + 1));
|
||||
assertAllTargetsCount(0);
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests null reply to property in message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void missingReplyToProperty() {
|
||||
final String controllerId = TARGET_PREFIX + "missingReplyToProperty";
|
||||
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
|
||||
@@ -215,9 +222,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests missing reply to property in message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void emptyReplyToProperty() {
|
||||
final String controllerId = TARGET_PREFIX + "emptyReplyToProperty";
|
||||
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
|
||||
@@ -228,9 +236,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests missing thing id property in message. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests missing thing id property in message. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void missingThingIdProperty() {
|
||||
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
|
||||
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
|
||||
@@ -240,9 +249,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests null thing id property in message. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests null thing id property in message. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void nullThingIdProperty() {
|
||||
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
|
||||
getDmfClient().send(createTargetMessage);
|
||||
@@ -251,9 +261,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests missing tenant message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests missing tenant message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void missingTenantHeader() {
|
||||
final String controllerId = TARGET_PREFIX + "missingTenantHeader";
|
||||
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
|
||||
@@ -264,9 +275,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests null tenant message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests null tenant message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void nullTenantHeader() {
|
||||
final String controllerId = TARGET_PREFIX + "nullTenantHeader";
|
||||
final Message createTargetMessage = createTargetMessage(controllerId, null);
|
||||
@@ -276,9 +288,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests empty tenant message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests empty tenant message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void emptyTenantHeader() {
|
||||
final String controllerId = TARGET_PREFIX + "emptyTenantHeader";
|
||||
final Message createTargetMessage = createTargetMessage(controllerId, "");
|
||||
@@ -288,9 +301,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertAllTargetsCount(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests missing type message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests missing type message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void missingTypeHeader() {
|
||||
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
|
||||
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE);
|
||||
@@ -301,9 +315,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
/**
|
||||
* Tests null type message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@ValueSource(strings = { "", "NotExist" })
|
||||
@NullSource
|
||||
@Description("Tests null type message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void shouldNotCreateTargetsWithInvalidTypeInHeader(String type) {
|
||||
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
|
||||
@@ -315,9 +331,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
/**
|
||||
* Tests null topic message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@ValueSource(strings = { "", "NotExist" })
|
||||
@NullSource
|
||||
@Description("Tests null topic message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void shouldNotSendMessagesWithInvalidTopic(String topic) {
|
||||
final Message eventMessage = createUpdateActionEventMessage("");
|
||||
@@ -327,9 +345,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests missing topic message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests missing topic message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void missingTopicHeader() {
|
||||
final Message eventMessage = createUpdateActionEventMessage("");
|
||||
eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC);
|
||||
@@ -339,9 +358,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
/**
|
||||
* Tests invalid null message content. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@ValueSource(strings = { "", "Invalid Content" })
|
||||
@NullSource
|
||||
@Description("Tests invalid null message content. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void shouldMoveUpdateActionStatusWithInvalidPayloadIntoDeadLetter(String payload) {
|
||||
final Message eventMessage = createUpdateActionEventMessage(payload);
|
||||
@@ -349,9 +370,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests invalid topic message header. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
/**
|
||||
* Tests invalid topic message header. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
|
||||
void updateActionStatusWithInvalidActionId() {
|
||||
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING);
|
||||
final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus);
|
||||
@@ -359,9 +381,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests register target and send finished message")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests register target and send finished message
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@@ -378,9 +401,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (running). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (running). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class),
|
||||
@@ -396,9 +420,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send an update action status (downloaded). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send an update action status (downloaded). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class),
|
||||
@@ -414,9 +439,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (download). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (download). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -431,9 +457,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (error). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (error). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@@ -449,9 +476,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (warning). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (warning). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -466,9 +494,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (retrieved). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (retrieved). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -483,9 +512,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -501,9 +531,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify receiving a download and install message if a deployment is done before the target has polled the first time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify receiving a download and install message if a deployment is done before the target has polled the first time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -530,9 +561,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -560,9 +592,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -590,9 +623,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -622,9 +656,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
Mockito.verifyNoInteractions(getDeadletterListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a invalid update action status (canceled). The current status (pending) is not a canceling state. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a invalid update action status (canceled). The current status (pending) is not a canceling state. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@@ -646,9 +681,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1),
|
||||
@@ -664,9 +700,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
|
||||
@@ -692,9 +729,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 4),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
@@ -718,9 +756,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that sending an update controller attribute message with no thingid header to an existing target does not work.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that sending an update controller attribute message with no thingid header to an existing target does not work.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
@@ -744,9 +783,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertUpdateAttributes(controllerId, controllerAttributeEmpty.getAttributes());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify that sending an update controller attribute message with invalid body to an existing target does not work.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
@@ -762,9 +802,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyOneDeadLetterMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that sending an UPDATE_ATTRIBUTES message with invalid attributes is handled correctly.")
|
||||
void updateAttributesWithInvalidValues() {
|
||||
/**
|
||||
* Verifies that sending an UPDATE_ATTRIBUTES message with invalid attributes is handled correctly.
|
||||
*/
|
||||
@Test void updateAttributesWithInvalidValues() {
|
||||
registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID);
|
||||
|
||||
sendUpdateAttributesMessageWithGivenAttributes(TargetTestData.ATTRIBUTE_KEY_TOO_LONG, TargetTestData.ATTRIBUTE_VALUE_VALID);
|
||||
@@ -774,9 +815,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyNumberOfDeadLetterMessages(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@@ -808,9 +850,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyAssignedDsAndInstalledDs(distributionSet.getId(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the download_only assignment: tests the handling of a target reporting FINISHED")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Tests the download_only assignment: tests the handling of a target reporting FINISHED
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 2),
|
||||
@@ -850,9 +893,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
verifyAssignedDsAndInstalledDs(distributionSet.getId(), distributionSet.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class) })
|
||||
void ignoredExceptionTypesShouldNotBeRequeued() {
|
||||
final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class);
|
||||
@@ -875,9 +919,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (confirmed). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (confirmed). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@@ -903,9 +948,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify the DMF confirmed feedback can be provided if confirmation flow is disabled
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 1),
|
||||
@@ -937,9 +983,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify the DMF confirmed feedback can be provided if confirmation flow is disabled
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class, count = 0),
|
||||
@@ -967,9 +1014,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertActionStatusList(actionId, 2, Status.WAIT_FOR_CONFIRMATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify the DMF download and install message is send directly if auto-confirmation is active")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Verify the DMF download and install message is send directly if auto-confirmation is active
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 2),
|
||||
@Expect(type = TargetPollEvent.class, count = 1),
|
||||
@@ -1001,9 +1049,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Register a target and send a update action status (denied). Verify if the updated action status is correct.")
|
||||
@ExpectEvents({
|
||||
/**
|
||||
* Register a target and send a update action status (denied). Verify if the updated action status is correct.
|
||||
*/
|
||||
@Test @ExpectEvents({
|
||||
@Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionUpdatedEvent.class),
|
||||
@@ -1032,7 +1081,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
return node.get("actionId").asText();
|
||||
}
|
||||
|
||||
@Step
|
||||
private void updateAttributesWithUpdateModeRemove() {
|
||||
|
||||
// assemble the expected attributes
|
||||
@@ -1053,7 +1101,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void updateAttributesWithUpdateModeMerge() {
|
||||
// get the current attributes
|
||||
final Map<String, String> attributes = new HashMap<>(
|
||||
@@ -1074,7 +1121,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void updateAttributesWithUpdateModeReplace() {
|
||||
// send an update message with update mode REPLACE
|
||||
final Map<String, String> expectedAttributes = new HashMap<>();
|
||||
@@ -1089,7 +1135,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void updateAttributesWithoutUpdateMode() {
|
||||
// send an update message which does not specify an update mode
|
||||
final Map<String, String> expectedAttributes = new HashMap<>();
|
||||
@@ -1103,7 +1148,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
|
||||
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyAssignedDsAndInstalledDs(final Long assignedDsId, final Long installedDsId) {
|
||||
final Optional<Target> target = controllerManagement.getByControllerId(DMF_REGISTER_TEST_CONTROLLER_ID);
|
||||
assertThat(target).isPresent();
|
||||
|
||||
Reference in New Issue
Block a user