Fix new line after @Test (#2486)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-06-20 17:42:55 +03:00
committed by GitHub
parent cb7f1107fe
commit ef25aa59f0
152 changed files with 2948 additions and 1474 deletions

View File

@@ -118,7 +118,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that download and install event with 3 software modules and no artifacts works
*/
@Test void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
@Test
void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
final DistributionSet createDistributionSet = testdataFactory
.createDistributionSet(UUID.randomUUID().toString());
testdataFactory.addSoftwareModuleMetadata(createDistributionSet);
@@ -158,7 +159,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that download and install event with software modules and artifacts works
*/
@Test void testSendDownloadRequest() {
@Test
void testSendDownloadRequest() {
DistributionSet dsA = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
SoftwareModule module = dsA.getModules().iterator().next();
final List<AbstractDbArtifact> receivedList = new ArrayList<>();
@@ -210,7 +212,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that sending update controller attributes event works.
*/
@Test void sendUpdateAttributesRequest() {
@Test
void sendUpdateAttributesRequest() {
final String amqpUri = "amqp://anyhost";
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT,
1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId());
@@ -224,7 +227,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that send cancel event works
*/
@Test void testSendCancelRequest() {
@Test
void testSendCancelRequest() {
final Action action = mock(Action.class);
when(action.getId()).thenReturn(1L);
when(action.getTenant()).thenReturn(TENANT);
@@ -241,7 +245,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that sending a delete message when receiving a delete event works.
*/
@Test void sendDeleteRequest() {
@Test
void sendDeleteRequest() {
// setup
final String amqpUri = "amqp://anyhost";
@@ -259,7 +264,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that a delete message is not send if the address is not an amqp address.
*/
@Test void sendDeleteRequestWithNoAmqpAddress() {
@Test
void sendDeleteRequestWithNoAmqpAddress() {
// setup
final String noAmqpUri = "http://anyhost";
@@ -276,7 +282,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
/**
* Verifies that a delete message is not send if the address is null.
*/
@Test void sendDeleteRequestWithNullAddress() {
@Test
void sendDeleteRequestWithNullAddress() {
// setup
final String noAmqpUri = null;

View File

@@ -145,7 +145,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests not allowed content-type in message
*/
@Test void wrongContentType() {
@Test
void wrongContentType() {
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setContentType("xml");
final Message message = new Message(new byte[0], messageProperties);
@@ -159,7 +160,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.
*/
@Test void createThing() {
@Test
void createThing() {
final String knownThingId = "1";
processThingCreatedMessage(knownThingId, null);
@@ -171,7 +173,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the creation of a target/thing with specified name by calling the same method that incoming RabbitMQ messages would access.
*/
@Test void createThingWithName() {
@Test
void createThingWithName() {
final String knownThingId = "2";
final String knownThingName = "NonDefaultTargetName";
@@ -187,7 +190,8 @@ class AmqpMessageHandlerServiceTest {
/**
* 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() {
@Test
void createThingWithType() {
final String knownThingId = "2";
final String knownThingTypeName = "TargetTypeName";
@@ -203,7 +207,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests not allowed body in message
*/
@Test void createThingWithWrongBody() {
@Test
void createThingWithWrongBody() {
final Message message = createMessage("Not allowed Body".getBytes(), getThingCreatedMessageProperties("3"));
final String type = MessageType.THING_CREATED.name();
assertThatExceptionOfType(MessageConversionException.class)
@@ -214,7 +219,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the creation of a target/thing with specified attributes by calling the same method that incoming RabbitMQ messages would access.
*/
@Test void createThingWithAttributes() {
@Test
void createThingWithAttributes() {
final String knownThingId = "4";
final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate();
@@ -231,7 +237,8 @@ class AmqpMessageHandlerServiceTest {
/**
* 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() {
@Test
void createThingWithNameAndAttributes() {
final String knownThingId = "5";
final String knownThingName = "NonDefaultTargetName";
@@ -250,7 +257,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the target attribute update by calling the same method that incoming RabbitMQ messages would access.
*/
@Test void updateAttributes() {
@Test
void updateAttributes() {
final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
@@ -271,7 +279,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Verifies that the update mode is retrieved from the UPDATE_ATTRIBUTES message and passed to the controller management.
*/
@Test void attributeUpdateModes() {
@Test
void attributeUpdateModes() {
final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
@@ -322,7 +331,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the creation of a thing without a 'reply to' header in message.
*/
@Test void createThingWithoutReplyTo() {
@Test
void createThingWithoutReplyTo() {
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null);
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
final Message message = createMessage("", messageProperties);
@@ -335,7 +345,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.
*/
@Test void createThingWithoutID() {
@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();
@@ -347,7 +358,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.
*/
@Test void unknownMessageType() {
@Test
void unknownMessageType() {
final String type = "bumlux";
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
messageProperties.setHeader(MessageHeaderKey.THING_ID, "");
@@ -361,7 +373,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests a invalid message without event topic
*/
@Test void invalidEventTopic() {
@Test
void invalidEventTopic() {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
final Message message = new Message(new byte[0], messageProperties);
@@ -384,7 +397,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the update of an action of a target without a exist action id
*/
@Test void updateActionStatusWithoutActionId() {
@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());
@@ -399,7 +413,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the update of an action of a target without a exist action id
*/
@Test void updateActionStatusWithoutExistActionId() {
@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());
@@ -416,7 +431,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests that messages which cause quota violations are not re-added to message queue so they would block other communication.
*/
@Test void quotaExceeded() {
@Test
void quotaExceeded() {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
@@ -442,7 +458,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Test next update is provided on finished action
*/
@Test void lookupNextUpdateActionAfterFinished() throws IllegalAccessException {
@Test
void lookupNextUpdateActionAfterFinished() throws IllegalAccessException {
// Mock
final Action action = createActionWithTarget(22L);
@@ -480,7 +497,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Test feedback code is persisted in messages when provided with DmfActionUpdateStatus
*/
@Test void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
@Test
void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
// Mock
final Action action = createActionWithTarget(22L);
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
@@ -515,7 +533,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the deletion of a target/thing, requested by the target itself.
*/
@Test void deleteThing() {
@Test
void deleteThing() {
// prepare valid message
final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED);
@@ -532,7 +551,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests the deletion of a target/thing with missing thingId
*/
@Test void deleteThingWithoutThingId() {
@Test
void deleteThingWithoutThingId() {
// prepare invalid message
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED);
final Message message = createMessage(new byte[0], messageProperties);
@@ -546,7 +566,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests activating auto-confirmation on a target.
*/
@Test void setAutoConfirmationStateActive() {
@Test
void setAutoConfirmationStateActive() {
final String knownThingId = "1";
final String initiator = "iAmTheInitiator";
final String remark = "remarkForTesting";
@@ -573,7 +594,8 @@ class AmqpMessageHandlerServiceTest {
/**
* Tests deactivating auto-confirmation on a target.
*/
@Test void setAutoConfirmationStateDeactivated() {
@Test
void setAutoConfirmationStateDeactivated() {
final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);

View File

@@ -51,7 +51,8 @@ class BaseAmqpServiceTest {
/**
* Verify that the message conversion works
*/
@Test void convertMessageTest() {
@Test
void convertMessageTest() {
final DmfActionUpdateStatus actionUpdateStatus = createActionStatus();
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());
@@ -63,7 +64,8 @@ class BaseAmqpServiceTest {
/**
* Tests invalid null message content
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void convertMessageWithNullContent() {
assertThatExceptionOfType(IllegalArgumentException.class)
.as("Expected IllegalArgumentException for invalid (null) JSON")
@@ -73,7 +75,8 @@ class BaseAmqpServiceTest {
/**
* Tests invalid empty message content
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void updateActionStatusWithEmptyContent() {
final Message message = createMessage("".getBytes());
assertThatExceptionOfType(MessageConversionException.class)
@@ -84,7 +87,8 @@ class BaseAmqpServiceTest {
/**
* Tests invalid json message content
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void updateActionStatusWithInvalidJsonContent() {
final Message message = createMessage("Invalid Json".getBytes());
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());

View File

@@ -30,7 +30,8 @@ class RequestExceptionStrategyTest {
/**
* Verifies that default handler is used if no handlers are defined for the specific exception.
*/
@Test void verifyDefaultFatal() {
@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();
}
@@ -38,7 +39,8 @@ class RequestExceptionStrategyTest {
/**
* Verifies additional fatal exception types are fatal.
*/
@Test void verifyAdditionalFatal() {
@Test
void verifyAdditionalFatal() {
assertThat(requeueExceptionStrategy.isFatal(new IllegalArgumentException())).isTrue();
assertThat(requeueExceptionStrategy.isFatal(new IndexOutOfBoundsException())).isTrue();
}
@@ -46,7 +48,8 @@ class RequestExceptionStrategyTest {
/**
* Verifies additional fatal exception types are fatal.
*/
@Test void verifyAdditionalWrappedFatal() {
@Test
void verifyAdditionalWrappedFatal() {
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IllegalArgumentException()))).isTrue();
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IndexOutOfBoundsException()))).isTrue();
}
@@ -54,7 +57,8 @@ class RequestExceptionStrategyTest {
/**
* Verifies that default handler is used if no handlers are defined for the specific exception.
*/
@Test void verifyNonFatal() {
@Test
void verifyNonFatal() {
assertThat(requeueExceptionStrategy.isFatal(new NullPointerException())).isFalse();
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new NullPointerException()))).isFalse();
}

View File

@@ -91,7 +91,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that a distribution assignment send a download and install message.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -112,7 +113,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -138,7 +140,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -164,7 +167,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@@ -211,7 +215,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* If multi assignment is enabled multi-action messages are sent.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -244,7 +249,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify payload of multi action messages.
*/
@Test void assertMultiActionMessagePayloads() {
@Test
void assertMultiActionMessagePayloads() {
final int expectedWeightIfNotSet = 1000;
final int weight1 = 600;
final String controllerId = UUID.randomUUID().toString();
@@ -294,7 +300,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Handle cancelation process of an action in multi assignment mode.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@@ -334,7 +341,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Handle finishing an action in multi assignment mode.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@@ -368,7 +376,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* If multi assignment is enabled assigning a DS multiple times creates a new action every time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -401,7 +410,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -440,7 +450,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 3),
@Expect(type = ActionCreatedEvent.class, count = 3),
@@ -492,7 +503,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that a cancel assignment send a cancel message.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@@ -517,7 +529,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that when a target is deleted a target delete message is send.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetDeletedEvent.class, count = 1) })
@@ -532,7 +545,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that attribute update is requested after device successfully closed software update.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@@ -562,7 +576,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -597,14 +612,16 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify payload of batch assignment download and install message.
*/
@Test void assertBatchAssignmentsDownloadAndInstall() {
@Test
void assertBatchAssignmentsDownloadAndInstall() {
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD_AND_INSTALL);
}
/**
* Verify payload of batch assignments download only message.
*/
@Test void assertBatchAssignmentsDownloadOnly() {
@Test
void assertBatchAssignmentsDownloadOnly() {
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD);
}
@@ -635,7 +652,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that batch and multi-assignments can't be activated at the same time.
*/
@Test void assertBatchAndMultiAssignmentsNotCompatible() {
@Test
void assertBatchAndMultiAssignmentsNotCompatible() {
enableBatchAssignments();
assertThatExceptionOfType(TenantConfigurationValueChangeNotAllowedException.class)
.isThrownBy(() -> enableMultiAssignments());
@@ -694,7 +712,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
/**
* Verify that a distribution assignment send a confirm message.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),

View File

@@ -94,7 +94,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests DMF PING request and expected response.
*/
@Test void pingDmfInterface() {
@Test
void pingDmfInterface() {
final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST);
getDmfClient().send(pingMessage);
@@ -106,7 +107,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests register target
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3) })
void registerTargets() {
@@ -123,7 +125,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests register target with name
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
@@ -142,7 +145,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests register target with attributes
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 2) })
@@ -164,7 +168,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests register target with name and attributes
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 2) })
@@ -201,7 +206,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests register invalid target with too long controller id
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void registerInvalidTargetWithTooLongControllerId() {
createAndSendThingCreated(randomString(Target.CONTROLLER_ID_MAX_SIZE + 1));
assertAllTargetsCount(0);
@@ -211,7 +217,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests null reply to property in message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingReplyToProperty() {
final String controllerId = TARGET_PREFIX + "missingReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -225,7 +232,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests missing reply to property in message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void emptyReplyToProperty() {
final String controllerId = TARGET_PREFIX + "emptyReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -239,7 +247,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests missing thing id property in message. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
@@ -252,7 +261,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests null thing id property in message. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nullThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
getDmfClient().send(createTargetMessage);
@@ -264,7 +274,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests missing tenant message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingTenantHeader() {
final String controllerId = TARGET_PREFIX + "missingTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -278,7 +289,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests null tenant message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nullTenantHeader() {
final String controllerId = TARGET_PREFIX + "nullTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, null);
@@ -291,7 +303,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests empty tenant message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void emptyTenantHeader() {
final String controllerId = TARGET_PREFIX + "emptyTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, "");
@@ -304,7 +317,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests missing type message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE);
@@ -348,7 +362,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests missing topic message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingTopicHeader() {
final Message eventMessage = createUpdateActionEventMessage("");
eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC);
@@ -373,7 +388,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests invalid topic message header. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void updateActionStatusWithInvalidActionId() {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING);
final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus);
@@ -384,7 +400,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests register target and send finished message
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -404,7 +421,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (running). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class),
@@ -423,7 +441,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send an update action status (downloaded). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class),
@@ -442,7 +461,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (download). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -460,7 +480,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (error). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -479,7 +500,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (warning). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -497,7 +519,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (retrieved). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -515,7 +538,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -534,7 +558,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify receiving a download and install message if a deployment is done before the target has polled the first time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -564,7 +589,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -595,7 +621,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -626,7 +653,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -659,7 +687,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* 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({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -684,7 +713,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@@ -703,7 +733,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@@ -732,7 +763,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* 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({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = TargetPollEvent.class, count = 1) })
@@ -759,7 +791,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify that sending an update controller attribute message with no thingid header to an existing target does not work.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class),
@Expect(type = TargetPollEvent.class, count = 1) })
@@ -786,7 +819,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify that sending an update controller attribute message with invalid body to an existing target does not work.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class),
@Expect(type = TargetPollEvent.class, count = 1) })
@@ -805,7 +839,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verifies that sending an UPDATE_ATTRIBUTES message with invalid attributes is handled correctly.
*/
@Test void updateAttributesWithInvalidValues() {
@Test
void updateAttributesWithInvalidValues() {
registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID);
sendUpdateAttributesMessageWithGivenAttributes(TargetTestData.ATTRIBUTE_KEY_TOO_LONG, TargetTestData.ATTRIBUTE_VALUE_VALID);
@@ -818,7 +853,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -853,7 +889,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Tests the download_only assignment: tests the handling of a target reporting FINISHED
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@@ -896,7 +933,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void ignoredExceptionTypesShouldNotBeRequeued() {
final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class);
@@ -922,7 +960,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (confirmed). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -951,7 +990,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify the DMF confirmed feedback can be provided if confirmation flow is disabled
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -986,7 +1026,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify the DMF confirmed feedback can be provided if confirmation flow is disabled
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0),
@@ -1017,7 +1058,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Verify the DMF download and install message is send directly if auto-confirmation is active
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@@ -1052,7 +1094,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
/**
* Register a target and send a update action status (denied). Verify if the updated action status is correct.
*/
@Test @ExpectEvents({
@Test
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class),