JPA Refactoring (2) (#2108)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-12-02 11:52:30 +02:00
committed by GitHub
parent 2a95adc562
commit 794f26bea2
41 changed files with 691 additions and 483 deletions

View File

@@ -255,9 +255,11 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
void sendConfirmedActionStateFeedbackTest() throws Exception { void sendConfirmedActionStateFeedbackTest() throws Exception {
enableConfirmationFlow(); enableConfirmationFlow();
@@ -419,7 +421,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
void testActionHistoryCount() throws Exception { void testActionHistoryCount() throws Exception {

View File

@@ -112,35 +112,6 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertThat(result.getRequest().getHeader("Accept")).isNull(); assertThat(result.getRequest().getHeader("Accept")).isNull();
} }
@Test
@Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists but can be created if the tenant exists.")
@WithUser(tenantId = "tenantDoesNotExists", allSpPermissions = true,
authorities = { CONTROLLER_ROLE, SYSTEM_ROLE }, autoCreateTenant = false)
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = DistributionSetTypeCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleTypeCreatedEvent.class, count = 2) })
void targetCannotBeRegisteredIfTenantDoesNotExistsButWhenExists() throws Exception {
mvc.perform(get("/default-tenant/", tenantAware.getCurrentTenant()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
// create tenant -- creates software module types and distribution set types
systemManagement.createTenantMetadata("tenantDoesNotExists");
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), "aControllerId"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
// delete tenant again, will also deleted target aControllerId
systemManagement.deleteTenant("tenantDoesNotExists");
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), "aControllerId"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
}
@Test @Test
@Description("Ensures that target poll request does not change audit data on the entity.") @Description("Ensures that target poll request does not change audit data on the entity.")
@WithUser(principal = "knownPrincipal", authorities = { SpPermission.READ_TARGET, SpPermission.UPDATE_TARGET, SpPermission.CREATE_TARGET }) @WithUser(principal = "knownPrincipal", authorities = { SpPermission.READ_TARGET, SpPermission.UPDATE_TARGET, SpPermission.CREATE_TARGET })
@@ -175,7 +146,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Test @Test
@Description("Ensures that server returns a not found response in case of empty controller ID.") @Description("Ensures that server returns a not found response in case of empty controller ID.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
void rootRsWithoutId() throws Exception { void rootRsWithoutId() throws Exception {
mvc.perform(get("/controller/v1/")) mvc.perform(get("/controller/v1/"))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -341,8 +313,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Test @Test
@Description("Ensures that the target state machine of a precomissioned target switches from " @Description("Ensures that the target state machine of a precomissioned target switches from "
+ "UNKNOWN to REGISTERED when the target polls for the first time.") + "UNKNOWN to REGISTERED when the target polls for the first time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void rootRsPreCommissioned() throws Exception { void rootRsPreCommissioned() throws Exception {
final String controllerId = "4711"; final String controllerId = "4711";
testdataFactory.createTarget(controllerId); testdataFactory.createTarget(controllerId);
@@ -572,7 +546,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1) }) @Expect(type = TargetAttributesRequestedEvent.class, count = 1) })
void testActionHistoryNegativeInput() throws Exception { void testActionHistoryNegativeInput() throws Exception {

View File

@@ -70,7 +70,7 @@ import org.springframework.test.context.ActiveProfiles;
@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE) @SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
private static final String TENANT = "default"; private static final String TENANT = "DEFAULT";
private static final Long TENANT_ID = 4711L; private static final Long TENANT_ID = 4711L;
private static final URI AMQP_URI = IpUtil.createAmqpUri("vHost", "mytest"); private static final URI AMQP_URI = IpUtil.createAmqpUri("vHost", "mytest");

View File

@@ -63,7 +63,8 @@ public class BaseAmqpServiceTest {
@Test @Test
@Description("Tests invalid null message content") @Description("Tests invalid null message content")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
public void convertMessageWithNullContent() { public void convertMessageWithNullContent() {
final Message message = createMessage("".getBytes()); final Message message = createMessage("".getBytes());
assertThatExceptionOfType(MessageConversionException.class) assertThatExceptionOfType(MessageConversionException.class)
@@ -73,7 +74,8 @@ public class BaseAmqpServiceTest {
@Test @Test
@Description("Tests invalid empty message content") @Description("Tests invalid empty message content")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
public void updateActionStatusWithEmptyContent() { public void updateActionStatusWithEmptyContent() {
final Message message = createMessage("".getBytes()); final Message message = createMessage("".getBytes());
assertThatExceptionOfType(MessageConversionException.class) assertThatExceptionOfType(MessageConversionException.class)
@@ -83,7 +85,8 @@ public class BaseAmqpServiceTest {
@Test @Test
@Description("Tests invalid json message content") @Description("Tests invalid json message content")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
public void updateActionStatusWithInvalidJsonContent() { public void updateActionStatusWithInvalidJsonContent() {
final Message message = createMessage("Invalid Json".getBytes()); final Message message = createMessage("Invalid Json".getBytes());
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());

View File

@@ -91,14 +91,16 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that a distribution assignment send a download and install message.") @Description("Verify that a distribution assignment send a download and install message.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void sendDownloadAndInstallStatus() { public void sendDownloadAndInstallStatus() {
final String controllerId = TARGET_PREFIX + "sendDownloadAndInstallStatus"; final String controllerId = TARGET_PREFIX + "sendDownloadAndInstallStatus";
registerTargetAndAssignDistributionSet(controllerId); registerTargetAndAssignDistributionSet(controllerId);
@@ -109,14 +111,16 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.") @Description("Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void sendDownloadStatusBeforeMaintenanceWindowStartTime() { public void sendDownloadStatusBeforeMaintenanceWindowStartTime() {
final String controllerId = TARGET_PREFIX + "sendDownloadStatusBeforeWindowStartTime"; final String controllerId = TARGET_PREFIX + "sendDownloadStatusBeforeWindowStartTime";
@@ -132,14 +136,16 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.") @Description("Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void sendDownloadAndInstallStatusMessageDuringMaintenanceWindow() { public void sendDownloadAndInstallStatusMessageDuringMaintenanceWindow() {
final String controllerId = TARGET_PREFIX + "sendDAndIStatusMessageDuringWindow"; final String controllerId = TARGET_PREFIX + "sendDAndIStatusMessageDuringWindow";
@@ -155,15 +161,18 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules") @Description("Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 18), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 18), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 3) }) @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3) })
public void assignDistributionSetMultipleTimes() { public void assignDistributionSetMultipleTimes() {
final String controllerId = TARGET_PREFIX + "assignDistributionSetMultipleTimes"; final String controllerId = TARGET_PREFIX + "assignDistributionSetMultipleTimes";
@@ -198,16 +207,19 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("If multi assignment is enabled multi-action messages are sent.") @Description("If multi assignment is enabled multi-action messages are sent.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@Expect(type = CancelTargetAssignmentEvent.class, count = 0), @Expect(type = CancelTargetAssignmentEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 0),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void assignMultipleDsInMultiAssignMode() { public void assignMultipleDsInMultiAssignMode() {
enableMultiAssignments(); enableMultiAssignments();
@@ -276,17 +288,20 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Handle cancelation process of an action in multi assignment mode.") @Description("Handle cancelation process of an action in multi assignment mode.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionCancelEvent.class, count = 1), @Expect(type = MultiActionCancelEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@Expect(type = CancelTargetAssignmentEvent.class, count = 0), @Expect(type = CancelTargetAssignmentEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void cancelActionInMultiAssignMode() { public void cancelActionInMultiAssignMode() {
enableMultiAssignments(); enableMultiAssignments();
@@ -311,17 +326,20 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Handle finishing an action in multi assignment mode.") @Description("Handle finishing an action in multi assignment mode.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@Expect(type = CancelTargetAssignmentEvent.class, count = 0), @Expect(type = CancelTargetAssignmentEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void finishActionInMultiAssignMode() { public void finishActionInMultiAssignMode() {
enableMultiAssignments(); enableMultiAssignments();
@@ -341,16 +359,19 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("If multi assignment is enabled assigning a DS multiple times creates a new action every time.") @Description("If multi assignment is enabled assigning a DS multiple times creates a new action every time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@Expect(type = CancelTargetAssignmentEvent.class, count = 0), @Expect(type = CancelTargetAssignmentEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 0),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
public void assignDsMultipleTimesInMultiAssignMode() { public void assignDsMultipleTimesInMultiAssignMode() {
enableMultiAssignments(); enableMultiAssignments();
@@ -370,17 +391,21 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.") @Description("If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@Expect(type = CancelTargetAssignmentEvent.class, count = 0), @Expect(type = CancelTargetAssignmentEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = RolloutCreatedEvent.class, count = 2), @Expect(type = RolloutUpdatedEvent.class, count = 6), @Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = RolloutCreatedEvent.class, count = 2),
@Expect(type = RolloutUpdatedEvent.class, count = 6),
@Expect(type = RolloutGroupCreatedEvent.class, count = 2), @Expect(type = RolloutGroupCreatedEvent.class, count = 2),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 4), @Expect(type = RolloutGroupUpdatedEvent.class, count = 4),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
@@ -404,16 +429,20 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.") @Description("If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 3), @Expect(type = MultiActionAssignEvent.class, count = 3),
@Expect(type = ActionCreatedEvent.class, count = 3), @Expect(type = ActionUpdatedEvent.class, count = 5), @Expect(type = ActionCreatedEvent.class, count = 3),
@Expect(type = ActionUpdatedEvent.class, count = 5),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 5), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 2), @Expect(type = TargetAttributesRequestedEvent.class, count = 2),
@Expect(type = RolloutCreatedEvent.class, count = 3), @Expect(type = RolloutUpdatedEvent.class, count = 9), @Expect(type = RolloutCreatedEvent.class, count = 3),
@Expect(type = RolloutUpdatedEvent.class, count = 9),
@Expect(type = RolloutGroupCreatedEvent.class, count = 3), @Expect(type = RolloutGroupCreatedEvent.class, count = 3),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 6), @Expect(type = RolloutGroupUpdatedEvent.class, count = 6),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
@@ -450,15 +479,18 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that a cancel assignment send a cancel message.") @Description("Verify that a cancel assignment send a cancel message.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
public void sendCancelStatus() { public void sendCancelStatus() {
final String controllerId = TARGET_PREFIX + "sendCancelStatus"; final String controllerId = TARGET_PREFIX + "sendCancelStatus";
@@ -471,8 +503,10 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that when a target is deleted a target delete message is send.") @Description("Verify that when a target is deleted a target delete message is send.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetDeletedEvent.class, count = 1) })
public void sendDeleteMessage() { public void sendDeleteMessage() {
final String controllerId = TARGET_PREFIX + "sendDeleteMessage"; final String controllerId = TARGET_PREFIX + "sendDeleteMessage";
@@ -483,9 +517,11 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that attribute update is requested after device successfully closed software update.") @Description("Verify that attribute update is requested after device successfully closed software update.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@@ -510,14 +546,16 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS") @Description("Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
public void downloadOnlyAssignmentSendsDownloadMessageTopic() { public void downloadOnlyAssignmentSendsDownloadMessageTopic() {
final String controllerId = TARGET_PREFIX + "registerTargets_1"; final String controllerId = TARGET_PREFIX + "registerTargets_1";
final DistributionSet distributionSet = createTargetAndDistributionSetAndAssign(controllerId, DOWNLOAD_ONLY); final DistributionSet distributionSet = createTargetAndDistributionSetAndAssign(controllerId, DOWNLOAD_ONLY);
@@ -591,14 +629,17 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@ParameterizedTest @ParameterizedTest
@EnumSource(names = { "BATCH_DOWNLOAD_AND_INSTALL", "BATCH_DOWNLOAD" }) @EnumSource(names = { "BATCH_DOWNLOAD_AND_INSTALL", "BATCH_DOWNLOAD" })
@Description("Verify payload of batch assignments.") @Description("Verify payload of batch assignments.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 3), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 3),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 3), @Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 3),
@Expect(type = ActionUpdatedEvent.class, count = 0),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 3), @Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 3),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
void assertBatchAssignmentsMessagePayload(final EventTopic topic) { void assertBatchAssignmentsMessagePayload(final EventTopic topic) {
enableBatchAssignments(); enableBatchAssignments();
@@ -629,7 +670,8 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test @Test
@Description("Verify that a distribution assignment send a confirm message.") @Description("Verify that a distribution assignment send a confirm message.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),

View File

@@ -107,7 +107,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests register target") @Description("Tests register target")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3) }) @Expect(type = TargetPollEvent.class, count = 3) })
void registerTargets() { void registerTargets() {
final String controllerId = TARGET_PREFIX + "registerTargets"; final String controllerId = TARGET_PREFIX + "registerTargets";
@@ -122,8 +123,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests register target with name") @Description("Tests register target with name")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
void registerTargetWithName() { void registerTargetWithName() {
final String controllerId = TARGET_PREFIX + "registerTargetWithName"; final String controllerId = TARGET_PREFIX + "registerTargetWithName";
final String name = "NonDefaultTargetName"; final String name = "NonDefaultTargetName";
@@ -138,8 +141,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests register target with attributes") @Description("Tests register target with attributes")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 2) })
void registerTargetWithAttributes() { void registerTargetWithAttributes() {
final String controllerId = TARGET_PREFIX + "registerTargetWithAttributes"; final String controllerId = TARGET_PREFIX + "registerTargetWithAttributes";
final Map<String, String> attributes = new HashMap<>(); final Map<String, String> attributes = new HashMap<>();
@@ -157,8 +162,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests register target with name and attributes") @Description("Tests register target with name and attributes")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 2) })
void registerTargetWithNameAndAttributes() { void registerTargetWithNameAndAttributes() {
final String controllerId = TARGET_PREFIX + "registerTargetWithAttributes"; final String controllerId = TARGET_PREFIX + "registerTargetWithAttributes";
final String name = "NonDefaultTargetName"; final String name = "NonDefaultTargetName";
@@ -180,7 +187,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@ValueSource(strings = { "", "Invalid Invalid" }) @ValueSource(strings = { "", "Invalid Invalid" })
@NullSource @NullSource
@Description("Tests register invalid target with empty controller id.") @Description("Tests register invalid target with empty controller id.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void shouldNotRegisterTargetsWithInvalidControllerIds(String controllerId) { void shouldNotRegisterTargetsWithInvalidControllerIds(String controllerId) {
createAndSendThingCreated(controllerId); createAndSendThingCreated(controllerId);
assertAllTargetsCount(0); assertAllTargetsCount(0);
@@ -189,7 +197,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests register invalid target with too long controller id") @Description("Tests register invalid target with too long controller id")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void registerInvalidTargetWithTooLongControllerId() { void registerInvalidTargetWithTooLongControllerId() {
createAndSendThingCreated(RandomStringUtils.randomAlphabetic(Target.CONTROLLER_ID_MAX_SIZE + 1)); createAndSendThingCreated(RandomStringUtils.randomAlphabetic(Target.CONTROLLER_ID_MAX_SIZE + 1));
assertAllTargetsCount(0); assertAllTargetsCount(0);
@@ -198,7 +207,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue") @Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void missingReplyToProperty() { void missingReplyToProperty() {
final String controllerId = TARGET_PREFIX + "missingReplyToProperty"; final String controllerId = TARGET_PREFIX + "missingReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -211,7 +221,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue") @Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void emptyReplyToProperty() { void emptyReplyToProperty() {
final String controllerId = TARGET_PREFIX + "emptyReplyToProperty"; final String controllerId = TARGET_PREFIX + "emptyReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -224,7 +235,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests missing thing id property in message. This message should forwarded to the deadletter queue") @Description("Tests missing thing id property in message. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void missingThingIdProperty() { void missingThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
@@ -236,7 +248,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests null thing id property in message. This message should forwarded to the deadletter queue") @Description("Tests null thing id property in message. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void nullThingIdProperty() { void nullThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
getDmfClient().send(createTargetMessage); getDmfClient().send(createTargetMessage);
@@ -247,7 +260,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests missing tenant message header. This message should forwarded to the deadletter queue") @Description("Tests missing tenant message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void missingTenantHeader() { void missingTenantHeader() {
final String controllerId = TARGET_PREFIX + "missingTenantHeader"; final String controllerId = TARGET_PREFIX + "missingTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -260,7 +274,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests null tenant message header. This message should forwarded to the deadletter queue") @Description("Tests null tenant message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void nullTenantHeader() { void nullTenantHeader() {
final String controllerId = TARGET_PREFIX + "nullTenantHeader"; final String controllerId = TARGET_PREFIX + "nullTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, null); final Message createTargetMessage = createTargetMessage(controllerId, null);
@@ -272,7 +287,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests empty tenant message header. This message should forwarded to the deadletter queue") @Description("Tests empty tenant message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void emptyTenantHeader() { void emptyTenantHeader() {
final String controllerId = TARGET_PREFIX + "emptyTenantHeader"; final String controllerId = TARGET_PREFIX + "emptyTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, ""); final Message createTargetMessage = createTargetMessage(controllerId, "");
@@ -282,21 +298,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test
@Description("Tests tenant not exist. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void tenantNotExist() {
final String controllerId = TARGET_PREFIX + "tenantNotExist";
final Message createTargetMessage = createTargetMessage(controllerId, "TenantNotExist");
getDmfClient().send(createTargetMessage);
verifyOneDeadLetterMessage();
assertThat(systemManagement.findTenants(PAGE)).hasSize(1);
}
@Test @Test
@Description("Tests missing type message header. This message should forwarded to the deadletter queue") @Description("Tests missing type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void missingTypeHeader() { void missingTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE);
@@ -310,7 +315,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@ValueSource(strings = { "", "NotExist" }) @ValueSource(strings = { "", "NotExist" })
@NullSource @NullSource
@Description("Tests null type message header. This message should forwarded to the deadletter queue") @Description("Tests null type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void shouldNotCreateTargetsWithInvalidTypeInHeader(String type) { void shouldNotCreateTargetsWithInvalidTypeInHeader(String type) {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, type); createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, type);
@@ -324,7 +330,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@ValueSource(strings = { "", "NotExist" }) @ValueSource(strings = { "", "NotExist" })
@NullSource @NullSource
@Description("Tests null topic message header. This message should forwarded to the deadletter queue") @Description("Tests null topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void shouldNotSendMessagesWithInvalidTopic(String topic) { void shouldNotSendMessagesWithInvalidTopic(String topic) {
final Message eventMessage = createUpdateActionEventMessage(""); final Message eventMessage = createUpdateActionEventMessage("");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, topic); eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, topic);
@@ -335,7 +342,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests missing topic message header. This message should forwarded to the deadletter queue") @Description("Tests missing topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void missingTopicHeader() { void missingTopicHeader() {
final Message eventMessage = createUpdateActionEventMessage(""); final Message eventMessage = createUpdateActionEventMessage("");
eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC); eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC);
@@ -348,7 +356,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@ValueSource(strings = { "", "Invalid Content" }) @ValueSource(strings = { "", "Invalid Content" })
@NullSource @NullSource
@Description("Tests invalid null message content. This message should forwarded to the deadletter queue") @Description("Tests invalid null message content. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void shouldMoveUpdateActionStatusWithInvalidPayloadIntoDeadLetter(String payload) { void shouldMoveUpdateActionStatusWithInvalidPayloadIntoDeadLetter(String payload) {
final Message eventMessage = createUpdateActionEventMessage(payload); final Message eventMessage = createUpdateActionEventMessage(payload);
getDmfClient().send(eventMessage); getDmfClient().send(eventMessage);
@@ -357,7 +366,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests invalid topic message header. This message should forwarded to the deadletter queue") @Description("Tests invalid topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void updateActionStatusWithInvalidActionId() { void updateActionStatusWithInvalidActionId() {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING);
final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus); final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus);
@@ -367,15 +377,18 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests register target and send finished message") @Description("Tests register target and send finished message")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1) })
void finishActionStatus() { void finishActionStatus() {
final String controllerId = TARGET_PREFIX + "finishActionStatus"; final String controllerId = TARGET_PREFIX + "finishActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId);
@@ -383,14 +396,17 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (running). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (running). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void runningActionStatus() { void runningActionStatus() {
final String controllerId = TARGET_PREFIX + "runningActionStatus"; final String controllerId = TARGET_PREFIX + "runningActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId);
@@ -398,14 +414,17 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send an update action status (downloaded). Verify if the updated action status is correct.") @Description("Register a target and send an update action status (downloaded). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void downloadedActionStatus() { void downloadedActionStatus() {
final String controllerId = TARGET_PREFIX + "downloadedActionStatus"; final String controllerId = TARGET_PREFIX + "downloadedActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId);
@@ -413,14 +432,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (download). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (download). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void downloadActionStatus() { void downloadActionStatus() {
final String controllerId = TARGET_PREFIX + "downloadActionStatus"; final String controllerId = TARGET_PREFIX + "downloadActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId);
@@ -428,14 +449,17 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (error). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (error). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1) })
void errorActionStatus() { void errorActionStatus() {
final String controllerId = TARGET_PREFIX + "errorActionStatus"; final String controllerId = TARGET_PREFIX + "errorActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId);
@@ -443,14 +467,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (warning). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (warning). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void warningActionStatus() { void warningActionStatus() {
final String controllerId = TARGET_PREFIX + "warningActionStatus"; final String controllerId = TARGET_PREFIX + "warningActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId);
@@ -458,14 +484,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (retrieved). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (retrieved). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void retrievedActionStatus() { void retrievedActionStatus() {
final String controllerId = TARGET_PREFIX + "retrievedActionStatus"; final String controllerId = TARGET_PREFIX + "retrievedActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId);
@@ -473,14 +501,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue") @Description("Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void cancelNotAllowActionStatus() { void cancelNotAllowActionStatus() {
final String controllerId = TARGET_PREFIX + "cancelNotAllowActionStatus"; final String controllerId = TARGET_PREFIX + "cancelNotAllowActionStatus";
registerTargetAndSendActionStatus(DmfActionStatus.CANCELED, controllerId); registerTargetAndSendActionStatus(DmfActionStatus.CANCELED, controllerId);
@@ -489,14 +519,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify receiving a download and install message if a deployment is done before the target has polled the first time.") @Description("Verify receiving a download and install message if a deployment is done before the target has polled the first time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
void receiveDownloadAndInstallMessageAfterAssignment() { void receiveDownloadAndInstallMessageAfterAssignment() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageAfterAssignment"; final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageAfterAssignment";
@@ -516,14 +548,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.") @Description("Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
void receiveDownloadMessageBeforeMaintenanceWindowStartTime() { void receiveDownloadMessageBeforeMaintenanceWindowStartTime() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadMessageBeforeMaintenanceWindowStartTime"; final String controllerId = TARGET_PREFIX + "receiveDownLoadMessageBeforeMaintenanceWindowStartTime";
@@ -544,14 +578,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.") @Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
void receiveDownloadAndInstallMessageDuringMaintenanceWindow() { void receiveDownloadAndInstallMessageDuringMaintenanceWindow() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageDuringMaintenanceWindow"; final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageDuringMaintenanceWindow";
@@ -572,7 +608,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.") @Description("Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@@ -580,7 +617,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetPollEvent.class, count = 2) })
void receiveCancelUpdateMessageAfterAssignmentWasCanceled() { void receiveCancelUpdateMessageAfterAssignmentWasCanceled() {
final String controllerId = TARGET_PREFIX + "receiveCancelUpdateMessageAfterAssignmentWasCanceled"; final String controllerId = TARGET_PREFIX + "receiveCancelUpdateMessageAfterAssignmentWasCanceled";
@@ -602,15 +640,18 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @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") @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({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void actionNotExists() { void actionNotExists() {
final String controllerId = TARGET_PREFIX + "actionNotExists"; final String controllerId = TARGET_PREFIX + "actionNotExists";
@@ -623,14 +664,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue") @Description("Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void canceledRejectedNotAllowActionStatus() { void canceledRejectedNotAllowActionStatus() {
final String controllerId = TARGET_PREFIX + "canceledRejectedNotAllowActionStatus"; final String controllerId = TARGET_PREFIX + "canceledRejectedNotAllowActionStatus";
registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED, controllerId); registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED, controllerId);
@@ -639,15 +682,18 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.") @Description("Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) })
void canceledRejectedActionStatus() { void canceledRejectedActionStatus() {
final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus"; final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus";
@@ -664,8 +710,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @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.") @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({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = TargetPollEvent.class, count = 1) })
void updateAttributesWithDifferentUpdateModes() { void updateAttributesWithDifferentUpdateModes() {
final String controllerId = TARGET_PREFIX + "updateAttributes"; final String controllerId = TARGET_PREFIX + "updateAttributes";
@@ -688,8 +736,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify that sending an update controller attribute message with no thingid header to an existing target does not work.") @Description("Verify that sending an update controller attribute message with no thingid header to an existing target does not work.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class),
@Expect(type = TargetPollEvent.class, count = 1) })
void updateAttributesWithNoThingId() { void updateAttributesWithNoThingId() {
final String controllerId = TARGET_PREFIX + "updateAttributesWithNoThingId"; final String controllerId = TARGET_PREFIX + "updateAttributesWithNoThingId";
@@ -713,8 +763,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.") @Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class),
@Expect(type = TargetPollEvent.class, count = 1) })
void updateAttributesWithWrongBody() { void updateAttributesWithWrongBody() {
// setup // setup
registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID); registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID);
@@ -745,15 +797,18 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED") @Description("Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1) })
void downloadOnlyAssignmentFinishesActionWhenTargetReportsDownloaded() throws IOException { void downloadOnlyAssignmentFinishesActionWhenTargetReportsDownloaded() throws IOException {
// create target // create target
final String controllerId = TARGET_PREFIX + "registerTargets_1"; final String controllerId = TARGET_PREFIX + "registerTargets_1";
@@ -776,15 +831,18 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Tests the download_only assignment: tests the handling of a target reporting FINISHED") @Description("Tests the download_only assignment: tests the handling of a target reporting FINISHED")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 9), // implicit lock
@Expect(type = TargetAttributesRequestedEvent.class, count = 2), @Expect(type = TargetAttributesRequestedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 1) })
void downloadOnlyAssignmentAllowsActionStatusUpdatesWhenTargetReportsFinishedAndUpdatesInstalledDS() void downloadOnlyAssignmentAllowsActionStatusUpdatesWhenTargetReportsFinishedAndUpdatesInstalledDS()
throws IOException { throws IOException {
// create target // create target
@@ -815,7 +873,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue") @Description("Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void ignoredExceptionTypesShouldNotBeRequeued() { void ignoredExceptionTypesShouldNotBeRequeued() {
final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class); final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class);
final List<Class<? extends RuntimeException>> exceptionsThatShouldNotBeRequeued = Arrays final List<Class<? extends RuntimeException>> exceptionsThatShouldNotBeRequeued = Arrays
@@ -839,7 +898,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (confirmed). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (confirmed). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -866,7 +926,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled") @Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -899,7 +960,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled") @Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionUpdatedEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -928,7 +990,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Verify the DMF download and install message is send directly if auto-confirmation is active") @Description("Verify the DMF download and install message is send directly if auto-confirmation is active")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionUpdatedEvent.class, count = 0),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -960,9 +1023,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Test @Test
@Description("Register a target and send a update action status (denied). Verify if the updated action status is correct.") @Description("Register a target and send a update action status (denied). Verify if the updated action status is correct.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock

View File

@@ -80,7 +80,7 @@ public class MgmtBasicAuthResourceTest {
@Autowired @Autowired
MockMvc defaultMock; MockMvc defaultMock;
private static final String TEST_USER = "testUser"; private static final String TEST_USER = "testUser";
private static final String DEFAULT = "default"; private static final String DEFAULT_TENANT = "DEFAULT";
@Test @Test
@Description("Test of userinfo api with basic auth validation") @Description("Test of userinfo api with basic auth validation")
@@ -92,7 +92,7 @@ public class MgmtBasicAuthResourceTest {
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaTypes.HAL_JSON_VALUE)) .andExpect(content().contentType(MediaTypes.HAL_JSON_VALUE))
.andExpect(jsonPath("$.username", equalTo(TEST_USER))) .andExpect(jsonPath("$.username", equalTo(TEST_USER)))
.andExpect(jsonPath("$.tenant", equalTo(DEFAULT))); .andExpect(jsonPath("$.tenant", equalTo(DEFAULT_TENANT)));
} }
@Test @Test

View File

@@ -61,7 +61,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verfies that a paged result list of DS tags reflects the content on the repository side.") @Description("Verfies that a paged result list of DS tags reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void getDistributionSetTags() throws Exception { public void getDistributionSetTags() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag assigned = tags.get(0); final DistributionSetTag assigned = tags.get(0);
@@ -161,7 +162,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verfies that a single result of a DS tag reflects the content on the repository side.") @Description("Verfies that a single result of a DS tag reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void getDistributionSetTag() throws Exception { public void getDistributionSetTag() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag assigned = tags.get(0); final DistributionSetTag assigned = tags.get(0);
@@ -179,7 +181,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verifies that created DS tags are stored in the repository as send to the API.") @Description("Verifies that created DS tags are stored in the repository as send to the API.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void createDistributionSetTags() throws Exception { public void createDistributionSetTags() throws Exception {
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
.build(); .build();
@@ -209,7 +212,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verifies that an updated DS tag is stored in the repository as send to the API.") @Description("Verifies that an updated DS tag is stored in the repository as send to the API.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagUpdatedEvent.class, count = 1) }) @Expect(type = DistributionSetTagUpdatedEvent.class, count = 1) })
public void updateDistributionSetTag() throws Exception { public void updateDistributionSetTag() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(1); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(1);
@@ -237,7 +241,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verfies that the delete call is reflected by the repository.") @Description("Verfies that the delete call is reflected by the repository.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagDeletedEvent.class, count = 1) }) @Expect(type = DistributionSetTagDeletedEvent.class, count = 1) })
public void deleteDistributionSetTag() throws Exception { public void deleteDistributionSetTag() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(1); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(1);
@@ -252,7 +257,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results.") @Description("Ensures that assigned DS to tag in repository are listed with proper paging results.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetCreatedEvent.class, count = 5),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
public void getAssignedDistributionSets() throws Exception { public void getAssignedDistributionSets() throws Exception {
@@ -271,7 +277,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter.") @Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetCreatedEvent.class, count = 5),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
public void getAssignedDistributionSetsWithPagingLimitRequestParameter() throws Exception { public void getAssignedDistributionSetsWithPagingLimitRequestParameter() throws Exception {
@@ -292,7 +299,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit and offset parameter.") @Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit and offset parameter.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetCreatedEvent.class, count = 5),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
public void getAssignedDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { public void getAssignedDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception {
@@ -316,7 +324,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verfies that tag assignments done through toggle API command are correctly assigned or unassigned.") @Description("Verfies that tag assignments done through toggle API command are correctly assigned or unassigned.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = DistributionSetUpdatedEvent.class, count = 4) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 4) })
public void toggleTagAssignment() throws Exception { public void toggleTagAssignment() throws Exception {
@@ -390,7 +399,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
@Test @Test
@Description("Verifies that tag unassignments done through tag API command are correctly stored in the repository.") @Description("Verifies that tag unassignments done through tag API command are correctly stored in the repository.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = DistributionSetUpdatedEvent.class, count = 3) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 3) })
public void unassignDistributionSet() throws Exception { public void unassignDistributionSet() throws Exception {

View File

@@ -68,7 +68,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Verfies that a paged result list of target tags reflects the content on the repository side.") @Description("Verfies that a paged result list of target tags reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void getTargetTags() throws Exception { public void getTargetTags() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(2, ""); final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
final TargetTag assigned = tags.get(0); final TargetTag assigned = tags.get(0);
@@ -131,7 +132,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Verfies that a single result of a target tag reflects the content on the repository side.") @Description("Verfies that a single result of a target tag reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void getTargetTag() throws Exception { public void getTargetTag() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(2, ""); final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
final TargetTag assigned = tags.get(0); final TargetTag assigned = tags.get(0);
@@ -150,7 +152,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Verifies that created target tags are stored in the repository as send to the API.") @Description("Verifies that created target tags are stored in the repository as send to the API.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void createTargetTags() throws Exception { public void createTargetTags() throws Exception {
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
.build(); .build();
@@ -180,7 +183,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Verifies that an updated target tag is stored in the repository as send to the API.") @Description("Verifies that an updated target tag is stored in the repository as send to the API.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetTagUpdatedEvent.class, count = 1) }) @Expect(type = TargetTagUpdatedEvent.class, count = 1) })
public void updateTargetTag() throws Exception { public void updateTargetTag() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(1, ""); final List<TargetTag> tags = testdataFactory.createTargetTags(1, "");
@@ -208,7 +212,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Verfies that the delete call is reflected by the repository.") @Description("Verfies that the delete call is reflected by the repository.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetTagDeletedEvent.class, count = 1) }) @Expect(type = TargetTagDeletedEvent.class, count = 1) })
public void deleteTargetTag() throws Exception { public void deleteTargetTag() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(1, ""); final List<TargetTag> tags = testdataFactory.createTargetTags(1, "");
@@ -223,8 +228,10 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Ensures that assigned targets to tag in repository are listed with proper paging results.") @Description("Ensures that assigned targets to tag in repository are listed with proper paging results.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 5), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 5),
@Expect(type = TargetUpdatedEvent.class, count = 5) })
public void getAssignedTargets() throws Exception { public void getAssignedTargets() throws Exception {
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0); final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
final int targetsAssigned = 5; final int targetsAssigned = 5;
@@ -241,8 +248,10 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter.") @Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 5), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 5),
@Expect(type = TargetUpdatedEvent.class, count = 5) })
public void getAssignedTargetsWithPagingLimitRequestParameter() throws Exception { public void getAssignedTargetsWithPagingLimitRequestParameter() throws Exception {
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0); final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
final int targetsAssigned = 5; final int targetsAssigned = 5;
@@ -261,8 +270,10 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Ensures that assigned targets to tag in repository are listed with proper paging results with paging limit and offset parameter.") @Description("Ensures that assigned targets to tag in repository are listed with proper paging results with paging limit and offset parameter.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 5), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 5),
@Expect(type = TargetUpdatedEvent.class, count = 5) })
public void getAssignedTargetsWithPagingLimitAndOffsetRequestParameter() throws Exception { public void getAssignedTargetsWithPagingLimitAndOffsetRequestParameter() throws Exception {
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0); final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
final int targetsAssigned = 5; final int targetsAssigned = 5;
@@ -612,8 +623,10 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
// DEPRECATED scenarios // DEPRECATED scenarios
@Test @Test
@Description("Verifes that tag assignments done through toggle API command are correctly assigned or unassigned.") @Description("Verifes that tag assignments done through toggle API command are correctly assigned or unassigned.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 4) }) @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 4) })
public void toggleTagAssignment() throws Exception { public void toggleTagAssignment() throws Exception {
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0); final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
final int targetsAssigned = 2; final int targetsAssigned = 2;
@@ -641,8 +654,10 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test @Test
@Description("Verfies that tag assignments done through tag API command are correctly stored in the repository.") @Description("Verfies that tag assignments done through tag API command are correctly stored in the repository.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2) }) @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2) })
public void assignTargetsByRequestBody() throws Exception { public void assignTargetsByRequestBody() throws Exception {
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0); final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
final int targetsAssigned = 2; final int targetsAssigned = 2;

View File

@@ -29,12 +29,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
*/ */
public interface SystemManagement { public interface SystemManagement {
/**
* Checks if a specific tenant exists. The tenant will not be created lazy.
*
* @return {@code true} in case the tenant exits or {@code false} if not
*/
String currentTenant();
/** /**
* Deletes all data related to a given tenant. * Deletes all data related to a given tenant.
@@ -113,13 +107,9 @@ public interface SystemManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
TenantMetaData updateTenantMetadata(long defaultDsType); TenantMetaData updateTenantMetadata(long defaultDsType);
/**
* Returns {@link TenantMetaData} of given tenant ID.
*
* @param tenantId to retrieve data for
* @return {@link TenantMetaData} of given tenant
*/
@PreAuthorize(SpringEvalExpressions.IS_SYSTEM_CODE) @PreAuthorize(SpringEvalExpressions.IS_SYSTEM_CODE)
TenantMetaData getTenantMetadata(long tenantId); TenantMetaData getTenantMetadata(long tenantId);
@PreAuthorize(SpringEvalExpressions.IS_SYSTEM_CODE)
boolean tenantExists(String tenant);
} }

View File

@@ -30,12 +30,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
@Story("Security Test") @Story("Security Test")
public class RepositoryManagementMethodPreAuthorizeAnnotatedTest { public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
// if some methods are to be excluded
private static final Set<Method> METHOD_SECURITY_EXCLUSION = new HashSet<>(); private static final Set<Method> METHOD_SECURITY_EXCLUSION = new HashSet<>();
static {
METHOD_SECURITY_EXCLUSION.add(getMethod(SystemManagement.class, "currentTenant"));
}
@Test @Test
@Description("Verifies that repository methods are @PreAuthorize annotated") @Description("Verifies that repository methods are @PreAuthorize annotated")
public void repositoryManagementMethodsArePreAuthorizedAnnotated() { public void repositoryManagementMethodsArePreAuthorizedAnnotated() {
@@ -74,16 +71,10 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
continue; continue;
} }
final PreAuthorize annotation = method.getAnnotation(PreAuthorize.class); final PreAuthorize annotation = method.getAnnotation(PreAuthorize.class);
assertThat(annotation).as("The public method " + method.getName() + " in class " + clazz.getName() assertThat(annotation)
+ " is not annotated with @PreAuthorize, security leak?").isNotNull(); .as("The public method " + method.getName() + " in class " + clazz.getName() +
" is not annotated with @PreAuthorize, security leak?")
.isNotNull();
} }
} }
}
private static Method getMethod(final Class<?> clazz, final String methodName, final Class<?>... parameterTypes) {
try {
return clazz.getMethod(methodName, parameterTypes);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
}

View File

@@ -36,11 +36,4 @@ public final class SystemManagementHolder {
public static SystemManagementHolder getInstance() { public static SystemManagementHolder getInstance() {
return INSTANCE; return INSTANCE;
} }
/**
* @return the {@link SystemManagement#currentTenant()}.
*/
public String currentTenant() {
return systemManagement.currentTenant();
}
} }

View File

@@ -86,7 +86,8 @@ public final class JpaManagementHelper {
public static <J extends AbstractJpaBaseEntity> J touch(final EntityManager entityManager, public static <J extends AbstractJpaBaseEntity> J touch(final EntityManager entityManager,
final CrudRepository<J, ?> repository, final J entity) { final CrudRepository<J, ?> repository, final J entity) {
// merge base entity so optLockRevision gets updated and auditing log written because modifying e.g. metadata is modifying the base // merge base entity so optLockRevision gets updated and audit
// log written because modifying e.g. metadata is modifying the base
// entity itself for auditing purposes. // entity itself for auditing purposes.
final J result = entityManager.merge(entity); final J result = entityManager.merge(entity);
result.setLastModifiedAt(0L); result.setLastModifiedAt(0L);

View File

@@ -42,9 +42,8 @@ public class ExceptionMappingAspectHandler implements Ordered {
private static final Map<String, String> EXCEPTION_MAPPING = new HashMap<>(4); private static final Map<String, String> EXCEPTION_MAPPING = new HashMap<>(4);
/** /**
* this is required to enable a certain order of exception and to select the * this is required to enable a certain order of exception and to select the most specific mappable exception according to the type
* most specific mappable exception according to the type hierarchy of the * hierarchy of the exception.
* exception.
*/ */
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4); private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4);
@@ -72,22 +71,18 @@ public class ExceptionMappingAspectHandler implements Ordered {
// It is a AspectJ proxy which deals with exceptions. // It is a AspectJ proxy which deals with exceptions.
@SuppressWarnings({ "squid:S00112", "squid:S1162" }) @SuppressWarnings({ "squid:S00112", "squid:S1162" })
public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable { public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {
// Workaround for EclipseLink merge where it does not throw ConstraintViolationException directly in case of existing entity update
// Workaround for EclipseLink merge where it does not throw ConstraintViolationException directly in case of
// existing entity update
if (ex instanceof TransactionSystemException) { if (ex instanceof TransactionSystemException) {
throw replaceWithCauseIfConstraintViolationException((TransactionSystemException) ex); throw replaceWithCauseIfConstraintViolationException((TransactionSystemException) ex);
} }
for (final Class<?> mappedEx : MAPPED_EXCEPTION_ORDER) { for (final Class<?> mappedEx : MAPPED_EXCEPTION_ORDER) {
if (!mappedEx.isAssignableFrom(ex.getClass())) { if (!mappedEx.isAssignableFrom(ex.getClass())) {
continue; continue;
} }
if (EXCEPTION_MAPPING.containsKey(mappedEx.getName())) { if (EXCEPTION_MAPPING.containsKey(mappedEx.getName())) {
throw (Exception) Class.forName(EXCEPTION_MAPPING.get(mappedEx.getName())) throw (Exception) Class.forName(EXCEPTION_MAPPING.get(mappedEx.getName())).getConstructor(Throwable.class).newInstance(ex);
.getConstructor(Throwable.class).newInstance(ex);
} }
log.error("there is no mapping configured for exception class {}", mappedEx.getName()); log.error("there is no mapping configured for exception class {}", mappedEx.getName());

View File

@@ -51,7 +51,8 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
@Override @Override
public JpaDistributionSet build() { public JpaDistributionSet build() {
return new JpaDistributionSet(name, version, description, return new JpaDistributionSet(
name, version, description,
Optional.ofNullable(type).map(this::findDistributionSetTypeWithExceptionIfNotFound).orElse(null), Optional.ofNullable(type).map(this::findDistributionSetTypeWithExceptionIfNotFound).orElse(null),
findSoftwareModuleWithExceptionIfNotFound(modules), findSoftwareModuleWithExceptionIfNotFound(modules),
Optional.ofNullable(requiredMigrationStep).orElse(Boolean.FALSE)); Optional.ofNullable(requiredMigrationStep).orElse(Boolean.FALSE));

View File

@@ -25,8 +25,7 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
/** /**
* {@link JpaTransactionManager} that sets the * {@link JpaTransactionManager} that sets the {@link TenantAware#getCurrentTenant()} in the eclipselink session. This has
* {@link TenantAware#getCurrentTenant()} in the eclipselink session. This has
* to be done in eclipselink after a {@link Transaction} has been started. * to be done in eclipselink after a {@link Transaction} has been started.
*/ */
public class MultiTenantJpaTransactionManager extends JpaTransactionManager { public class MultiTenantJpaTransactionManager extends JpaTransactionManager {

View File

@@ -66,8 +66,7 @@ public class JpaActionManagement {
} }
protected List<JpaAction> findActiveActionsHavingStatus(final String controllerId, final Action.Status status) { protected List<JpaAction> findActiveActionsHavingStatus(final String controllerId, final Action.Status status) {
return actionRepository.findAll( return actionRepository.findAll(ActionSpecifications.byTargetControllerIdAndIsActiveAndStatus(controllerId, status));
ActionSpecifications.byTargetControllerIdAndIsActiveAndStatus(controllerId, status));
} }
protected Action addActionStatus(final JpaActionStatusCreate statusCreate) { protected Action addActionStatus(final JpaActionStatusCreate statusCreate) {

View File

@@ -64,20 +64,15 @@ import org.springframework.validation.annotation.Validated;
public class JpaDistributionSetTypeManagement implements DistributionSetTypeManagement { public class JpaDistributionSetTypeManagement implements DistributionSetTypeManagement {
private final DistributionSetTypeRepository distributionSetTypeRepository; private final DistributionSetTypeRepository distributionSetTypeRepository;
private final SoftwareModuleTypeRepository softwareModuleTypeRepository; private final SoftwareModuleTypeRepository softwareModuleTypeRepository;
private final DistributionSetRepository distributionSetRepository; private final DistributionSetRepository distributionSetRepository;
private final TargetTypeRepository targetTypeRepository; private final TargetTypeRepository targetTypeRepository;
private final VirtualPropertyReplacer virtualPropertyReplacer; private final VirtualPropertyReplacer virtualPropertyReplacer;
private final Database database; private final Database database;
private final QuotaManagement quotaManagement; private final QuotaManagement quotaManagement;
public JpaDistributionSetTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository, public JpaDistributionSetTypeManagement(
final DistributionSetTypeRepository distributionSetTypeRepository,
final SoftwareModuleTypeRepository softwareModuleTypeRepository, final SoftwareModuleTypeRepository softwareModuleTypeRepository,
final DistributionSetRepository distributionSetRepository, final TargetTypeRepository targetTypeRepository, final DistributionSetRepository distributionSetRepository, final TargetTypeRepository targetTypeRepository,
final VirtualPropertyReplacer virtualPropertyReplacer, final Database database, final VirtualPropertyReplacer virtualPropertyReplacer, final Database database,

View File

@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.CurrentTenantCacheKeyGenerator; import org.eclipse.hawkbit.repository.jpa.CurrentTenantCacheKeyGenerator;
import org.eclipse.hawkbit.repository.jpa.SystemManagementCacheKeyGenerator; import org.eclipse.hawkbit.repository.jpa.SystemManagementCacheKeyGenerator;
import org.eclipse.hawkbit.repository.jpa.configuration.Constants; import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
import org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType; import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
import org.eclipse.hawkbit.repository.jpa.model.JpaTenantMetaData; import org.eclipse.hawkbit.repository.jpa.model.JpaTenantMetaData;
@@ -141,16 +140,6 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
return currentTenantCacheKeyGenerator.currentTenantKeyGenerator(); return currentTenantCacheKeyGenerator.currentTenantKeyGenerator();
} }
@Override
@Cacheable(value = "currentTenant", keyGenerator = "currentTenantKeyGenerator", cacheManager = "directCacheManager", unless = "#result == null")
public String currentTenant() {
return currentTenantCacheKeyGenerator.getTenantInCreation().orElseGet(() -> {
final TenantMetaData findByTenant = tenantMetaDataRepository
.findByTenantIgnoreCase(tenantAware.getCurrentTenant());
return findByTenant != null ? findByTenant.getTenant() : null;
});
}
@Override @Override
@Transactional @Transactional
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, @Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
@@ -295,6 +284,12 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
.orElseThrow(() -> new EntityNotFoundException(TenantMetaData.class, tenantId)); .orElseThrow(() -> new EntityNotFoundException(TenantMetaData.class, tenantId));
} }
@Override
@Cacheable(value = "currentTenant", keyGenerator = "currentTenantKeyGenerator", cacheManager = "directCacheManager", unless = "#result == null")
public boolean tenantExists(final String tenant) {
return tenantMetaDataRepository.findByTenantIgnoreCase(tenant) != null;
}
private static boolean isPostgreSql(final JpaProperties properties) { private static boolean isPostgreSql(final JpaProperties properties) {
return Database.POSTGRESQL == properties.getDatabase(); return Database.POSTGRESQL == properties.getDatabase();
} }
@@ -342,13 +337,13 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
} }
/** /**
* Creating the initial tenant meta-data in a new transaction. Due the * Creating the initial tenant meta-data in a new transaction. Due to the
* {@link MultiTenantJpaTransactionManager} is using the current tenant to * {@link org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager} is using the current tenant to
* set the necessary tenant discriminator to the query. This is not working * set the necessary tenant discriminator to the query. This is not working
* if we don't have a current tenant set. Due the * if we don't have a current tenant set. Due to the
* {@link #createTenantMetadata(String)} is maybe called without having a * {@link #createTenantMetadata(String)} is maybe called without having a
* current tenant we need to re-open a new transaction so the * current tenant we need to re-open a new transaction so the
* {@link MultiTenantJpaTransactionManager} is called again and set the * {@link org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager} is called again and set the
* tenant for this transaction. * tenant for this transaction.
* *
* @param tenant the tenant to be created * @param tenant the tenant to be created

View File

@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
import org.eclipse.persistence.annotations.Multitenant; import org.eclipse.persistence.annotations.Multitenant;
import org.eclipse.persistence.annotations.MultitenantType; import org.eclipse.persistence.annotations.MultitenantType;
import org.eclipse.persistence.annotations.TenantDiscriminatorColumn; import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
import org.hibernate.annotations.TenantId;
/** /**
* Holder of the base attributes common to all tenant aware entities. * Holder of the base attributes common to all tenant aware entities.
@@ -88,11 +89,14 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
/** /**
* PrePersist listener method for all {@link TenantAwareBaseEntity} entities. * PrePersist listener method for all {@link TenantAwareBaseEntity} entities.
*
* // TODO - check if the tenant support should set tenant from context
* // TODO - should we check if tenant exists in the system? Note: seems it's not good to work with db in the listener
*/ */
@PrePersist @PrePersist
void prePersist() { void prePersist() {
// before persisting the entity check the current ID of the tenant by using the TenantAware service // before persisting the entity check the current ID of the tenant by using the TenantAware service
final String currentTenant = SystemManagementHolder.getInstance().currentTenant(); final String currentTenant = TenantAwareHolder.getInstance().getTenantAware().getCurrentTenant();
if (currentTenant == null) { if (currentTenant == null) {
throw new TenantNotExistException( throw new TenantNotExistException(
String.format( String.format(

View File

@@ -71,7 +71,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
*/ */
@Modifying @Modifying
@Transactional @Transactional
@Query("UPDATE JpaAction a SET a.status = :statusToSet WHERE a.target IN :targetsIds AND a.active = :active AND a.status = :currentStatus AND a.distributionSet.requiredMigrationStep = false") @Query("UPDATE JpaAction a SET a.status = :statusToSet WHERE a.target.id IN :targetsIds AND a.active = :active AND a.status = :currentStatus AND a.distributionSet.requiredMigrationStep = false")
void switchStatus(@Param("statusToSet") Action.Status statusToSet, @Param("targetsIds") List<Long> targetIds, void switchStatus(@Param("statusToSet") Action.Status statusToSet, @Param("targetsIds") List<Long> targetIds,
@Param("active") boolean active, @Param("currentStatus") Action.Status currentStatus); @Param("active") boolean active, @Param("currentStatus") Action.Status currentStatus);

View File

@@ -16,6 +16,7 @@ import java.util.Optional;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.acm.AccessController; import org.eclipse.hawkbit.repository.jpa.acm.AccessController;
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaBaseEntity_; import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaBaseEntity_;
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaTenantAwareBaseEntity; import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaTenantAwareBaseEntity;
@@ -65,6 +66,17 @@ public interface BaseEntityRepository<T extends AbstractJpaTenantAwareBaseEntity
@Override @Override
List<T> findAll(); List<T> findAll();
/**
* Gets by id requiring entity to exists
*
* @param id the entity id
* @return the existing entity.
* @throws EntityNotFoundException if the entity doesn't exist
*/
default T getById(final Long id) {
return findById(id).orElseThrow(() -> new EntityNotFoundException(getDomainClass(), id));
}
/** /**
* Overrides * Overrides
* {@link org.springframework.data.repository.CrudRepository#findAllById(Iterable)} * {@link org.springframework.data.repository.CrudRepository#findAllById(Iterable)}

View File

@@ -67,9 +67,9 @@ import org.junit.jupiter.api.Test;
public class ArtifactManagementTest extends AbstractJpaIntegrationTest { public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access react as specfied on calls for non existing entities by means " @Description("Verifies that management get access react as specfied on calls for non existing entities by means of Optional not present.")
+ "of Optional not present.") @ExpectEvents({
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
public void nonExistingEntityAccessReturnsNotPresent() { public void nonExistingEntityAccessReturnsNotPresent() {
final SoftwareModule module = testdataFactory.createSoftwareModuleOs(); final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
@@ -85,7 +85,8 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = SoftwareModuleDeletedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = SoftwareModuleDeletedEvent.class, count = 0) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException { public void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException {
final String artifactData = "test"; final String artifactData = "test";
@@ -319,10 +320,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
} }
@Test @Test
@Description("Test the deletion of an artifact metadata where the binary is still linked to another " @Description("Test the deletion of an artifact metadata where the binary is still linked to another metadata element. " +
+ "metadata element. The expected result is that the metadata is deleted but the binary kept.") "The expected result is that the metadata is deleted but the binary kept.")
public void deleteDuplicateArtifacts() throws IOException { public void deleteDuplicateArtifacts() throws IOException {
final JpaSoftwareModule sm = softwareModuleRepository final JpaSoftwareModule sm = softwareModuleRepository
.save(new JpaSoftwareModule(osType, "name 1", "version 1")); .save(new JpaSoftwareModule(osType, "name 1", "version 1"));
final JpaSoftwareModule sm2 = softwareModuleRepository final JpaSoftwareModule sm2 = softwareModuleRepository
@@ -334,29 +334,21 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
try (final InputStream inputStream1 = new ByteArrayInputStream(randomBytes); try (final InputStream inputStream1 = new ByteArrayInputStream(randomBytes);
final InputStream inputStream2 = new ByteArrayInputStream(randomBytes)) { final InputStream inputStream2 = new ByteArrayInputStream(randomBytes)) {
final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1); final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1);
final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize, final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize, inputStream2);
inputStream2);
assertThat(artifactRepository.findAll()).hasSize(2);
assertThat(artifact1.getId()).isNotNull(); assertThat(artifact1.getId()).isNotNull();
assertThat(artifact2.getId()).isNotNull(); assertThat(artifact2.getId()).isNotNull();
assertThat(((JpaArtifact) artifact1).getSha1Hash()).isEqualTo(((JpaArtifact) artifact2).getSha1Hash()); assertThat((artifact1).getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
assertThat(artifactRepository.findAll()).hasSize(2);
assertThat( assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNotNull();
binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNotNull();
artifactManagement.delete(artifact1.getId()); artifactManagement.delete(artifact1.getId());
assertThat(
binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNotNull();
assertThat(artifactRepository.findAll()).hasSize(1);
assertThat(artifactRepository.existsById(artifact1.getId())).isFalse(); assertThat(artifactRepository.existsById(artifact1.getId())).isFalse();
assertThat(artifactRepository.findAll()).hasSize(1);
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNotNull();
artifactManagement.delete(artifact2.getId()); artifactManagement.delete(artifact2.getId());
assertThat( assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNull();
binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNull();
assertThat(artifactRepository.findAll()).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0);
} }
} }
@@ -435,8 +427,8 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
public void findArtifact() throws IOException { public void findArtifact() throws IOException {
final int artifactSize = 5 * 1024; final int artifactSize = 5 * 1024;
try (final InputStream inputStream = new RandomGeneratedInputStream(artifactSize)) { try (final InputStream inputStream = new RandomGeneratedInputStream(artifactSize)) {
final Artifact artifact = createArtifactForSoftwareModule("file1", final Artifact artifact = createArtifactForSoftwareModule(
testdataFactory.createSoftwareModuleOs().getId(), artifactSize, inputStream); "file1", testdataFactory.createSoftwareModuleOs().getId(), artifactSize, inputStream);
assertThat(artifactManagement.get(artifact.getId()).get()).isEqualTo(artifact); assertThat(artifactManagement.get(artifact.getId()).get()).isEqualTo(artifact);
} }
} }

View File

@@ -68,6 +68,7 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException; import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction_; import org.eclipse.hawkbit.repository.jpa.model.JpaAction_;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget; import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository; import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications; import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications;
@@ -101,7 +102,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that target attribute update fails if quota hits.") @Description("Ensures that target attribute update fails if quota hits.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2) }) @Expect(type = TargetUpdatedEvent.class, count = 2) })
public void updateTargetAttributesFailsIfTooManyEntries() throws Exception { public void updateTargetAttributesFailsIfTooManyEntries() throws Exception {
final String controllerId = "test123"; final String controllerId = "test123";
@@ -165,12 +167,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller providing status entries fails if providing more than permitted by quota.") @Description("Controller providing status entries fails if providing more than permitted by quota.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
public void controllerProvidesIntermediateFeedbackFailsIfQuotaHit() { public void controllerProvidesIntermediateFeedbackFailsIfQuotaHit() {
final int allowStatusEntries = 10; final int allowStatusEntries = 10;
@@ -213,12 +217,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that the quota specifying the maximum number of status entries per action is enforced.") @Description("Verifies that the quota specifying the maximum number of status entries per action is enforced.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 2) })
public void addActionStatusUpdatesUntilQuotaIsExceeded() { public void addActionStatusUpdatesUntilQuotaIsExceeded() {
@@ -251,12 +257,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that the quota specifying the maximum number of messages per action status is enforced.") @Description("Verifies that the quota specifying the maximum number of messages per action status is enforced.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
public void createActionStatusWithTooManyMessages() { public void createActionStatusWithTooManyMessages() {
@@ -281,12 +289,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that a DOWNLOAD_ONLY action is not marked complete when the controller reports DOWNLOAD") @Description("Verifies that a DOWNLOAD_ONLY action is not marked complete when the controller reports DOWNLOAD")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
public void controllerReportsDownloadForDownloadOnlyAction() { public void controllerReportsDownloadForDownloadOnlyAction() {
testdataFactory.createTarget(); testdataFactory.createTarget();
@@ -305,7 +315,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access react as specified on calls for non existing entities by means " @Description("Verifies that management get access react as specified on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
@@ -326,7 +337,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specified on calls for non existing entities " @Description("Verifies that management queries react as specified on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException { void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
@@ -362,12 +374,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller confirms successful update with FINISHED status.") @Description("Controller confirms successful update with FINISHED status.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1) }) @Expect(type = TargetAttributesRequestedEvent.class, count = 1) })
@@ -387,12 +401,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller confirmation fails with invalid messages.") @Description("Controller confirmation fails with invalid messages.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
void controllerConfirmationFailsWithInvalidMessages() { void controllerConfirmationFailsWithInvalidMessages() {
final Long actionId = createTargetAndAssignDs(); final Long actionId = createTargetAndAssignDs();
@@ -417,12 +433,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller confirms successful update with FINISHED status on a action that is on canceling. " @Description("Controller confirms successful update with FINISHED status on a action that is on canceling. "
+ "Reason: The decision to ignore the cancellation is in fact up to the controller.") + "Reason: The decision to ignore the cancellation is in fact up to the controller.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@@ -442,12 +460,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Update server rejects cancellation feedback if action is not in CANCELING state.") @Description("Update server rejects cancellation feedback if action is not in CANCELING state.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
void cancellationFeedbackRejectedIfActionIsNotInCanceling() { void cancellationFeedbackRejectedIfActionIsNotInCanceling() {
final Long actionId = createTargetAndAssignDs(); final Long actionId = createTargetAndAssignDs();
@@ -466,12 +486,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller confirms action cancellation with FINISHED status.") @Description("Controller confirms action cancellation with FINISHED status.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -495,12 +517,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller confirms action cancellation with FINISHED status.") @Description("Controller confirms action cancellation with FINISHED status.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -525,12 +549,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller rejects action cancellation with CANCEL_REJECTED status. Action goes back to RUNNING status as it expects " @Description("Controller rejects action cancellation with CANCEL_REJECTED status. Action goes back to RUNNING status as it expects "
+ "that the controller will continue the original update.") + "that the controller will continue the original update.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -555,12 +581,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller rejects action cancellation with ERROR status. Action goes back to RUNNING status as it expects " @Description("Controller rejects action cancellation with ERROR status. Action goes back to RUNNING status as it expects "
+ "that the controller will continue the original update.") + "that the controller will continue the original update.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -585,12 +613,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that assignment verification works based on SHA1 hash. By design it is not important which artifact " @Description("Verifies that assignment verification works based on SHA1 hash. By design it is not important which artifact "
+ "is actually used for the check as long as they have an identical binary, i.e. same SHA1 hash. ") + "is actually used for the check as long as they have an identical binary, i.e. same SHA1 hash. ")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 5), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 5), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
void hasTargetArtifactAssignedIsTrueWithMultipleArtifacts() { void hasTargetArtifactAssignedIsTrueWithMultipleArtifacts() {
final int artifactSize = 5 * 1024; final int artifactSize = 5 * 1024;
@@ -654,7 +684,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist with existing target type and update its target type to another existing one") @Description("Register a controller which does not exist with existing target type and update its target type to another existing one")
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 2), @ExpectEvents({
@Expect(type = TargetTypeCreatedEvent.class, count = 2),
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1) })
@@ -676,7 +707,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist with existing target type and update its target type to non existing one") @Description("Register a controller which does not exist with existing target type and update its target type to non existing one")
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetPollEvent.class, count = 2) })
void findOrRegisterTargetIfItDoesNotExistWithExistingTypeAndUpdateToNonExistingType() { void findOrRegisterTargetIfItDoesNotExistWithExistingTypeAndUpdateToNonExistingType() {
@@ -694,7 +726,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist with existing target type and unassign its target type") @Description("Register a controller which does not exist with existing target type and unassign its target type")
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1) })
@@ -713,7 +746,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist without target type and update its target type to existing one") @Description("Register a controller which does not exist without target type and update its target type to existing one")
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1) })
@@ -734,7 +768,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist with non existing target type and update its target type to existing one") @Description("Register a controller which does not exist with non existing target type and update its target type to existing one")
@WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE })
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTypeCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1) })
@@ -796,7 +831,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist, when a ConcurrencyFailureException is raised, the " @Description("Register a controller which does not exist, when a ConcurrencyFailureException is raised, the "
+ "exception is not rethrown when the max retries are not yet reached") + "exception is not rethrown when the max retries are not yet reached")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
void findOrRegisterTargetIfItDoesNotExistDoesNotThrowExceptionBeforeMaxRetries() { void findOrRegisterTargetIfItDoesNotExistDoesNotThrowExceptionBeforeMaxRetries() {
@@ -822,8 +858,10 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Register a controller which does not exist, then update the controller twice, first time by providing a name property and second time without a new name") @Description("Register a controller which does not exist, then update the controller twice, first time by providing a name property and second time without a new name")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetPollEvent.class, count = 3), @Expect(type = TargetUpdatedEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 3),
@Expect(type = TargetUpdatedEvent.class, count = 1) })
void findOrRegisterTargetIfItDoesNotExistDoesUpdateNameOnExistingTargetProperly() { void findOrRegisterTargetIfItDoesNotExistDoesUpdateNameOnExistingTargetProperly() {
final String controllerId = "12345"; final String controllerId = "12345";
@@ -889,7 +927,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that targetVisible metadata is returned from repository") @Description("Verify that targetVisible metadata is returned from repository")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6) }) @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6) })
void findTargetVisibleMetaDataBySoftwareModuleId() { void findTargetVisibleMetaDataBySoftwareModuleId() {
@@ -906,7 +945,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that controller registration does not result in a TargetPollEvent if feature is disabled") @Description("Verify that controller registration does not result in a TargetPollEvent if feature is disabled")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 0) }) @Expect(type = TargetPollEvent.class, count = 0) })
void targetPollEventNotSendIfDisabled() { void targetPollEventNotSendIfDisabled() {
repositoryProperties.setPublishTargetPollEvent(false); repositoryProperties.setPublishTargetPollEvent(false);
@@ -916,12 +956,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller tries to finish an update process after it has been finished by an error action status.") @Description("Controller tries to finish an update process after it has been finished by an error action status.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
void tryToFinishWithErrorUpdateProcessMoreThanOnce() { void tryToFinishWithErrorUpdateProcessMoreThanOnce() {
@@ -964,12 +1006,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller tries to finish an update process after it has been finished by an FINISHED action status.") @Description("Controller tries to finish an update process after it has been finished by an FINISHED action status.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1) }) @Expect(type = TargetAttributesRequestedEvent.class, count = 1) })
@@ -1003,12 +1047,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller tries to send an update feedback after it has been finished which is reject as the repository is " @Description("Controller tries to send an update feedback after it has been finished which is reject as the repository is "
+ "configured to reject that.") + "configured to reject that.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1) }) @Expect(type = TargetAttributesRequestedEvent.class, count = 1) })
@@ -1034,7 +1080,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Controller tries to send an update feedback after it has been finished which is accepted as the repository is " @Description("Controller tries to send an update feedback after it has been finished which is accepted as the repository is "
+ "configured to accept them.") + "configured to accept them.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@@ -1063,7 +1110,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that target attribute update is reflected by the repository.") @Description("Ensures that target attribute update is reflected by the repository.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3) }) @Expect(type = TargetUpdatedEvent.class, count = 3) })
void updateTargetAttributes() throws Exception { void updateTargetAttributes() throws Exception {
final String controllerId = "test123"; final String controllerId = "test123";
@@ -1110,12 +1158,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that a DOWNLOAD_ONLY action is marked complete once the controller reports DOWNLOADED") @Description("Verifies that a DOWNLOAD_ONLY action is marked complete once the controller reports DOWNLOADED")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -1123,10 +1173,9 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTarget(); testdataFactory.createTarget();
final Long actionId = createAndAssignDsAsDownloadOnly("downloadOnlyDs", DEFAULT_CONTROLLER_ID); final Long actionId = createAndAssignDsAsDownloadOnly("downloadOnlyDs", DEFAULT_CONTROLLER_ID);
assertThat(actionId).isNotNull(); assertThat(actionId).isNotNull();
controllerManagement controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.DOWNLOADED));
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.DOWNLOADED)); assertActionStatus(
assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.DOWNLOADED, actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.DOWNLOADED, Action.Status.DOWNLOADED, false);
Action.Status.DOWNLOADED, false);
assertThat(actionStatusRepository.count()).isEqualTo(2); assertThat(actionStatusRepository.count()).isEqualTo(2);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2);
@@ -1135,12 +1184,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that a controller can report a FINISHED event for a DOWNLOAD_ONLY non-active action.") @Description("Verifies that a controller can report a FINISHED event for a DOWNLOAD_ONLY non-active action.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetAttributesRequestedEvent.class, count = 2), @Expect(type = TargetAttributesRequestedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -1160,7 +1211,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that multiple DOWNLOADED events for a DOWNLOAD_ONLY action are handled.") @Description("Verifies that multiple DOWNLOADED events for a DOWNLOAD_ONLY action are handled.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@@ -1188,12 +1240,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that quota is asserted when a controller reports too many DOWNLOADED events for a " @Description("Verifies that quota is asserted when a controller reports too many DOWNLOADED events for a "
+ "DOWNLOAD_ONLY action.") + "DOWNLOAD_ONLY action.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 9), @Expect(type = TargetAttributesRequestedEvent.class, count = 9),
@Expect(type = ActionUpdatedEvent.class, count = 1) }) @Expect(type = ActionUpdatedEvent.class, count = 1) })
@@ -1210,12 +1264,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that quota is enforced for UpdateActionStatus events for DOWNLOAD_ONLY assignments.") @Description("Verifies that quota is enforced for UpdateActionStatus events for DOWNLOAD_ONLY assignments.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetAttributesRequestedEvent.class, count = 10), @Expect(type = TargetAttributesRequestedEvent.class, count = 10),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@@ -1254,7 +1310,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that quota is enforced for UpdateActionStatus events for FORCED assignments.") @Description("Verifies that quota is enforced for UpdateActionStatus events for FORCED assignments.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@@ -1352,7 +1409,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that assigning version form target works") @Description("Verify that assigning version form target works")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), @Expect(type = DistributionSetUpdatedEvent.class, count = 1),
@@ -1392,12 +1450,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that a target can report FINISHED/ERROR updates for DOWNLOAD_ONLY assignments regardless of " @Description("Verifies that a target can report FINISHED/ERROR updates for DOWNLOAD_ONLY assignments regardless of "
+ "repositoryProperties.rejectActionStatusForClosedAction value.") + "repositoryProperties.rejectActionStatusForClosedAction value.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 4), @Expect(type = DistributionSetCreatedEvent.class, count = 4),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 12), @Expect(type = SoftwareModuleCreatedEvent.class, count = 12),
@Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 12), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 12), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 4), @Expect(type = TargetUpdatedEvent.class, count = 12), @Expect(type = ActionCreatedEvent.class, count = 4),
@Expect(type = TargetUpdatedEvent.class, count = 12),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 4), @Expect(type = TargetAssignDistributionSetEvent.class, count = 4),
@Expect(type = TargetAttributesRequestedEvent.class, count = 6), @Expect(type = TargetAttributesRequestedEvent.class, count = 6),
@Expect(type = ActionUpdatedEvent.class, count = 8) }) @Expect(type = ActionUpdatedEvent.class, count = 8) })
@@ -1435,12 +1495,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that a controller can report a FINISHED event for a DOWNLOAD_ONLY action after having" @Description("Verifies that a controller can report a FINISHED event for a DOWNLOAD_ONLY action after having"
+ " installed an intermediate update.") + " installed an intermediate update.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 5), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 5),
@Expect(type = TargetAttributesRequestedEvent.class, count = 3), @Expect(type = TargetAttributesRequestedEvent.class, count = 3),
@Expect(type = ActionUpdatedEvent.class, count = 3), @Expect(type = ActionUpdatedEvent.class, count = 3),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2) }) @Expect(type = TargetAssignDistributionSetEvent.class, count = 2) })
@@ -1506,8 +1568,10 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Delete a target on requested target deletion from client side") @Description("Delete a target on requested target deletion from client side")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetDeletedEvent.class, count = 1) })
void deleteTargetWithValidThingId() { void deleteTargetWithValidThingId() {
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST);
assertThat(target).as("target should not be null").isNotNull(); assertThat(target).as("target should not be null").isNotNull();
@@ -1520,7 +1584,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Delete a target with a non existing thingId") @Description("Delete a target with a non existing thingId")
@ExpectEvents({ @Expect(type = TargetDeletedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetDeletedEvent.class, count = 0) })
void deleteTargetWithInvalidThingId() { void deleteTargetWithInvalidThingId() {
assertThatExceptionOfType(EntityNotFoundException.class) assertThatExceptionOfType(EntityNotFoundException.class)
.as("No EntityNotFoundException thrown when deleting a non-existing target") .as("No EntityNotFoundException thrown when deleting a non-existing target")
@@ -1530,8 +1595,10 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Delete a target after it has been deleted already") @Description("Delete a target after it has been deleted already")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetDeletedEvent.class, count = 1) })
void deleteTargetAfterItWasDeleted() { void deleteTargetAfterItWasDeleted() {
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST);
assertThat(target).as("target should not be null").isNotNull(); assertThat(target).as("target should not be null").isNotNull();
@@ -1574,13 +1641,12 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Step @Step
private Long createAndAssignDsAsDownloadOnly(final String dsName, final String defaultControllerId) { private Long createAndAssignDsAsDownloadOnly(final String dsName, final String defaultControllerId) {
final Long dsId = testdataFactory.createDistributionSet(dsName).getId(); final DistributionSet ds = testdataFactory.createDistributionSet(dsName);
final Long dsId = ds.getId();
assignDistributionSet(dsId, defaultControllerId, DOWNLOAD_ONLY); assignDistributionSet(dsId, defaultControllerId, DOWNLOAD_ONLY);
assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()) assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
.isEqualTo(TargetUpdateStatus.PENDING);
final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0) final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0).getId();
.getId();
assertThat(id).isNotNull(); assertThat(id).isNotNull();
return id; return id;
} }

View File

@@ -146,7 +146,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access react as specified on calls for non existing entities by means " + @Description("Verifies that management get access react as specified on calls for non existing entities by means " +
"of Optional not present.") "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
assertThat(deploymentManagement.findAction(1234L)).isNotPresent(); assertThat(deploymentManagement.findAction(1234L)).isNotPresent();
assertThat(deploymentManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent(); assertThat(deploymentManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent();
@@ -155,7 +156,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specified on calls for non existing entities " + @Description("Verifies that management queries react as specified on calls for non existing entities " +
" by means of throwing EntityNotFoundException.") " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final String dsName = "DistributionSet"; final String dsName = "DistributionSet";
@@ -307,7 +309,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.") @Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 20), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 20),
@Expect(type = TargetUpdatedEvent.class, count = 40), @Expect(type = TargetUpdatedEvent.class, count = 40),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = ActionCreatedEvent.class, count = 40), @Expect(type = ActionCreatedEvent.class, count = 40),
@@ -491,8 +494,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Simple offline deployment of a distribution set to a list of targets. Verifies that offline assigment " @Description("Simple offline deployment of a distribution set to a list of targets. Verifies that offline assigment "
+ "is correctly executed for targets that do not have a running update already. Those are ignored.") + "is correctly executed for targets that do not have a running update already. Those are ignored.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 20), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 20), @Expect(type = ActionCreatedEvent.class, count = 20), @Expect(type = TargetCreatedEvent.class, count = 20),
@Expect(type = TargetUpdatedEvent.class, count = 20),
@Expect(type = ActionCreatedEvent.class, count = 20),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@@ -535,8 +540,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Offline assign multiple DSs to a single Target in multiassignment mode.") @Description("Offline assign multiple DSs to a single Target in multiassignment mode.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = ActionCreatedEvent.class, count = 4), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = ActionCreatedEvent.class, count = 4),
@Expect(type = DistributionSetCreatedEvent.class, count = 4), @Expect(type = DistributionSetCreatedEvent.class, count = 4),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 12), @Expect(type = SoftwareModuleCreatedEvent.class, count = 12),
@Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock
@@ -571,8 +578,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that if an account is set to action autoclose running actions in case of a new assigned set get closed and set to CANCELED.") @Description("Verifies that if an account is set to action autoclose running actions in case of a new assigned set get closed and set to CANCELED.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 10), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 20), @Expect(type = ActionCreatedEvent.class, count = 20), @Expect(type = TargetCreatedEvent.class, count = 10),
@Expect(type = TargetUpdatedEvent.class, count = 20),
@Expect(type = ActionCreatedEvent.class, count = 20),
@Expect(type = ActionUpdatedEvent.class, count = 10), @Expect(type = ActionUpdatedEvent.class, count = 10),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@@ -612,8 +621,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("If multi-assignment is enabled, verify that the previous Distribution Set assignment is not canceled when a new one is assigned.") @Description("If multi-assignment is enabled, verify that the previous Distribution Set assignment is not canceled when a new one is assigned.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 10), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 20), @Expect(type = ActionCreatedEvent.class, count = 20), @Expect(type = TargetCreatedEvent.class, count = 10),
@Expect(type = TargetUpdatedEvent.class, count = 20),
@Expect(type = ActionCreatedEvent.class, count = 20),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@@ -643,8 +654,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Assign multiple DSs to a single Target in one request in multiassignment mode.") @Description("Assign multiple DSs to a single Target in one request in multiassignment mode.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = ActionCreatedEvent.class, count = 4), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = ActionCreatedEvent.class, count = 4),
@Expect(type = DistributionSetCreatedEvent.class, count = 4), @Expect(type = DistributionSetCreatedEvent.class, count = 4),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 12), @Expect(type = SoftwareModuleCreatedEvent.class, count = 12),
@Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock
@@ -679,8 +692,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Assign multiple DSs to single Target in one request in multiAssignment mode and cancel each created action afterwards.") @Description("Assign multiple DSs to single Target in one request in multiAssignment mode and cancel each created action afterwards.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = ActionCreatedEvent.class, count = 4), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = ActionCreatedEvent.class, count = 4),
@Expect(type = DistributionSetCreatedEvent.class, count = 4), @Expect(type = DistributionSetCreatedEvent.class, count = 4),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 12), @Expect(type = SoftwareModuleCreatedEvent.class, count = 12),
@Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 4), // implicit lock
@@ -900,13 +915,15 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Duplicate Assignments are removed from a request when multiassignment is disabled, otherwise not") @Description("Duplicate Assignments are removed from a request when multiassignment is disabled, otherwise not")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = MultiActionAssignEvent.class, count = 1), @Expect(type = MultiActionAssignEvent.class, count = 1),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
void duplicateAssignmentsInRequestAreRemovedIfMultiassignmentEnabled() { void duplicateAssignmentsInRequestAreRemovedIfMultiassignmentEnabled() {
@@ -928,7 +945,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("An assignment request is not accepted if it would lead to a target exceeding the max actions per target quota.") @Description("An assignment request is not accepted if it would lead to a target exceeding the max actions per target quota.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 21), // max actions per target are 20 for test @Expect(type = DistributionSetCreatedEvent.class, count = 21), // max actions per target are 20 for test
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3 * 21), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3 * 21),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -980,12 +998,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Weights are validated and contained in the resulting Action.") @Description("Weights are validated and contained in the resulting Action.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TenantConfigurationCreatedEvent.class, count = 1) }) @Expect(type = TenantConfigurationCreatedEvent.class, count = 1) })
void weightValidatedAndSaved() { void weightValidatedAndSaved() {
@@ -1019,12 +1039,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
*/ */
@Test @Test
@Description("Simple deployment or distribution set to target assignment test.") @Description("Simple deployment or distribution set to target assignment test.")
@ExpectEvents({ @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetCreatedEvent.class, count = 30), @Expect(type = ActionCreatedEvent.class, count = 20), @Expect(type = TargetCreatedEvent.class, count = 30),
@Expect(type = ActionCreatedEvent.class, count = 20),
@Expect(type = TargetUpdatedEvent.class, count = 20) }) @Expect(type = TargetUpdatedEvent.class, count = 20) })
void assignDistributionSet2Targets() { void assignDistributionSet2Targets() {
@@ -1078,12 +1100,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Test that it is not possible to assign a distribution set that is not complete.") @Description("Test that it is not possible to assign a distribution set that is not complete.")
@ExpectEvents({ @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 2), @Expect(type = SoftwareModuleCreatedEvent.class, count = 2),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 2), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = TargetCreatedEvent.class, count = 10), @Expect(type = ActionCreatedEvent.class, count = 10), @Expect(type = TargetCreatedEvent.class, count = 10),
@Expect(type = ActionCreatedEvent.class, count = 10),
@Expect(type = TargetUpdatedEvent.class, count = 10) }) @Expect(type = TargetUpdatedEvent.class, count = 10) })
void failDistributionSetAssigmentThatIsNotComplete() throws InterruptedException { void failDistributionSetAssigmentThatIsNotComplete() throws InterruptedException {
final List<Target> targets = testdataFactory.createTargets(10); final List<Target> targets = testdataFactory.createTargets(10);
@@ -1108,7 +1132,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Multiple deployments or distribution set to target assignment test. Expected behaviour is that a new deployment " @Description("Multiple deployments or distribution set to target assignment test. Expected behaviour is that a new deployment "
+ "overides unfinished old one which are canceled as part of the operation.") + "overides unfinished old one which are canceled as part of the operation.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5 + 4), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 5 + 4),
@Expect(type = TargetUpdatedEvent.class, count = 3 * 4), @Expect(type = TargetUpdatedEvent.class, count = 3 * 4),
@Expect(type = ActionCreatedEvent.class, count = 3 * 4), @Expect(type = ActionCreatedEvent.class, count = 3 * 4),
@Expect(type = ActionUpdatedEvent.class, count = 4 * 2), @Expect(type = ActionUpdatedEvent.class, count = 4 * 2),

View File

@@ -92,7 +92,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access react as specified on calls for non existing entities by means " @Description("Verifies that management get access react as specified on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) }) @Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
final DistributionSet set = testdataFactory.createDistributionSet(); final DistributionSet set = testdataFactory.createDistributionSet();
@@ -105,7 +106,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 4) }) @Expect(type = SoftwareModuleCreatedEvent.class, count = 4) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
@@ -202,7 +204,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that a DistributionSet with invalid properties cannot be created or updated") @Description("Verify that a DistributionSet with invalid properties cannot be created or updated")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class) }) @Expect(type = DistributionSetUpdatedEvent.class) })
void createAndUpdateDistributionSetWithInvalidFields() { void createAndUpdateDistributionSetWithInvalidFields() {
@@ -941,7 +944,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that the find all by ids contains the entities which are looking for") @Description("Verify that the find all by ids contains the entities which are looking for")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 12), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 12),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 36) }) @Expect(type = SoftwareModuleCreatedEvent.class, count = 36) })
void verifyFindDistributionSetAllById() { void verifyFindDistributionSetAllById() {
final List<Long> searchIds = new ArrayList<>(); final List<Long> searchIds = new ArrayList<>();

View File

@@ -54,7 +54,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present.") @Description("Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent(); assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();

View File

@@ -55,7 +55,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
@Test @Test
@Description("Verifies that management get access react as specfied on calls for non existing entities by means " @Description("Verifies that management get access react as specfied on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 0) })
public void nonExistingEntityAccessReturnsNotPresent() { public void nonExistingEntityAccessReturnsNotPresent() {
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent(); assertThat(distributionSetTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
@@ -65,7 +66,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 0),
@Expect(type = DistributionSetTypeCreatedEvent.class, count = 1) }) @Expect(type = DistributionSetTypeCreatedEvent.class, count = 1) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() { public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
@@ -93,7 +95,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
@Test @Test
@Description("Verify that a DistributionSet with invalid properties cannot be created or updated") @Description("Verify that a DistributionSet with invalid properties cannot be created or updated")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 0) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 0) })
public void createAndUpdateDistributionSetWithInvalidFields() { public void createAndUpdateDistributionSetWithInvalidFields() {

View File

@@ -39,7 +39,8 @@ public class LazyControllerManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verfies that lazy target poll update is executed as specified.") @Description("Verfies that lazy target poll update is executed as specified.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetPollEvent.class, count = 2) })
public void lazyFindOrRegisterTargetIfItDoesNotexist() throws InterruptedException { public void lazyFindOrRegisterTargetIfItDoesNotexist() throws InterruptedException {
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST);

View File

@@ -49,7 +49,8 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means " + @Description("Verifies that management get access reacts as specified on calls for non existing entities by means " +
"of Optional not present.") "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
assertThat(rolloutGroupManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(rolloutGroupManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(rolloutGroupManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent(); assertThat(rolloutGroupManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
@@ -58,7 +59,8 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specified on calls for non existing entities " + @Description("Verifies that management queries react as specified on calls for non existing entities " +
" by means of throwing EntityNotFoundException.") " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0), @ExpectEvents({
@Expect(type = RolloutDeletedEvent.class, count = 0),
@Expect(type = RolloutGroupCreatedEvent.class, count = 5), @Expect(type = RolloutGroupCreatedEvent.class, count = 5),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5), @Expect(type = RolloutGroupUpdatedEvent.class, count = 5),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),

View File

@@ -283,7 +283,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means " @Description("Verifies that management get access reacts as specified on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
assertThat(rolloutManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(rolloutManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(rolloutManagement.getByName(NOT_EXIST_ID)).isNotPresent(); assertThat(rolloutManagement.getByName(NOT_EXIST_ID)).isNotPresent();
@@ -293,14 +294,16 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specified on calls for non existing entities " @Description("Verifies that management queries react as specified on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0), @ExpectEvents({
@Expect(type = RolloutDeletedEvent.class, count = 0),
@Expect(type = RolloutGroupCreatedEvent.class, count = 5), @Expect(type = RolloutGroupCreatedEvent.class, count = 5),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5), @Expect(type = RolloutGroupUpdatedEvent.class, count = 5),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = RolloutCreatedEvent.class, count = 1), @Expect(type = RolloutUpdatedEvent.class, count = 1), @Expect(type = RolloutCreatedEvent.class, count = 1),
@Expect(type = RolloutUpdatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 125) }) @Expect(type = TargetCreatedEvent.class, count = 125) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
testdataFactory.createRollout("xxx"); testdataFactory.createRollout("xxx");
@@ -1766,8 +1769,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
} }
@Test @Test
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 25), @Expect(type = RolloutUpdatedEvent.class, count = 2), @Expect(type = RolloutDeletedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 25),
@Expect(type = RolloutUpdatedEvent.class, count = 2),
@Expect(type = RolloutGroupCreatedEvent.class, count = 5), @Expect(type = RolloutGroupCreatedEvent.class, count = 5),
@Expect(type = RolloutGroupDeletedEvent.class, count = 5), @Expect(type = RolloutGroupDeletedEvent.class, count = 5),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@@ -1798,16 +1803,19 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
} }
@Test @Test
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @ExpectEvents({
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10), @Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
@Expect(type = RolloutUpdatedEvent.class, count = 6), @Expect(type = RolloutUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 1), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 3), // implicit lock
@Expect(type = TargetCreatedEvent.class, count = 25), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetCreatedEvent.class, count = 25),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = RolloutGroupCreatedEvent.class, count = 5), @Expect(type = RolloutGroupCreatedEvent.class, count = 5),
@Expect(type = ActionCreatedEvent.class, count = 10), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 10),
@Expect(type = ActionUpdatedEvent.class, count = 2),
@Expect(type = RolloutDeletedEvent.class, count = 1), @Expect(type = RolloutDeletedEvent.class, count = 1),
@Expect(type = RolloutCreatedEvent.class, count = 1) }) @Expect(type = RolloutCreatedEvent.class, count = 1) })
void deleteRolloutWhichHasBeenStartedBeforeIsSoftDeleted() { void deleteRolloutWhichHasBeenStartedBeforeIsSoftDeleted() {

View File

@@ -62,7 +62,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means " @Description("Verifies that management get access reacts as specified on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
public void nonExistingEntityAccessReturnsNotPresent() { public void nonExistingEntityAccessReturnsNotPresent() {
final SoftwareModule module = testdataFactory.createSoftwareModuleApp(); final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
@@ -77,7 +78,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() { public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
final SoftwareModule module = testdataFactory.createSoftwareModuleApp(); final SoftwareModule module = testdataFactory.createSoftwareModuleApp();

View File

@@ -37,7 +37,8 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means " @Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
public void nonExistingEntityAccessReturnsNotPresent() { public void nonExistingEntityAccessReturnsNotPresent() {
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
@@ -48,7 +49,8 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() { public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL), "SoftwareModuleType"); verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL), "SoftwareModuleType");

View File

@@ -68,13 +68,13 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
// per tenant data // per tenant data
final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants(); final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants();
assertThat(tenants).hasSize(3); assertThat(tenants).hasSize(3);
final TenantUsage tenantUsage0 = new TenantUsage("tenant0"); final TenantUsage tenantUsage0 = new TenantUsage("TENANT0");
tenantUsage0.setArtifacts(1); tenantUsage0.setArtifacts(1);
tenantUsage0.setOverallArtifactVolumeInBytes(1234); tenantUsage0.setOverallArtifactVolumeInBytes(1234);
final TenantUsage tenantUsage1 = new TenantUsage("tenant1"); final TenantUsage tenantUsage1 = new TenantUsage("TENANT1");
tenantUsage1.setArtifacts(1); tenantUsage1.setArtifacts(1);
tenantUsage1.setOverallArtifactVolumeInBytes(1234); tenantUsage1.setOverallArtifactVolumeInBytes(1234);
assertThat(tenants).containsOnly(new TenantUsage("default"), assertThat(tenants).containsOnly(new TenantUsage("DEFAULT"),
tenantUsage0, tenantUsage0,
tenantUsage1); tenantUsage1);
} }
@@ -92,13 +92,11 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
// per tenant data // per tenant data
final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants(); final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants();
assertThat(tenants).hasSize(3); assertThat(tenants).hasSize(3);
final TenantUsage tenantUsage0 = new TenantUsage("tenant0"); final TenantUsage tenantUsage0 = new TenantUsage("TENANT0");
tenantUsage0.setTargets(100); tenantUsage0.setTargets(100);
final TenantUsage tenantUsage1 = new TenantUsage("tenant1"); final TenantUsage tenantUsage1 = new TenantUsage("TENANT1");
tenantUsage1.setTargets(100); tenantUsage1.setTargets(100);
assertThat(tenants).containsOnly(new TenantUsage("default"), assertThat(tenants).containsOnly(new TenantUsage("DEFAULT"), tenantUsage0, tenantUsage1);
tenantUsage0,
tenantUsage1);
} }
@Test @Test
@@ -113,15 +111,13 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
// per tenant data // per tenant data
final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants(); final List<TenantUsage> tenants = systemManagement.getSystemUsageStatisticsWithTenants().getTenants();
assertThat(tenants).hasSize(3); assertThat(tenants).hasSize(3);
final TenantUsage tenantUsage0 = new TenantUsage("tenant0"); final TenantUsage tenantUsage0 = new TenantUsage("TENANT0");
tenantUsage0.setTargets(20); tenantUsage0.setTargets(20);
tenantUsage0.setActions(40); tenantUsage0.setActions(40);
final TenantUsage tenantUsage1 = new TenantUsage("tenant1"); final TenantUsage tenantUsage1 = new TenantUsage("TENANT1");
tenantUsage1.setTargets(20); tenantUsage1.setTargets(20);
tenantUsage1.setActions(40); tenantUsage1.setActions(40);
assertThat(tenants).containsOnly(new TenantUsage("default"), assertThat(tenants).containsOnly(new TenantUsage("DEFAULT"), tenantUsage0, tenantUsage1);
tenantUsage0,
tenantUsage1);
} }
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
@@ -131,7 +127,7 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
randomgen.nextBytes(random); randomgen.nextBytes(random);
for (int i = 0; i < tenants; i++) { for (int i = 0; i < tenants; i++) {
final String tenantname = "tenant" + i; final String tenantname = "TENANT" + i;
SecurityContextSwitch.runAs(SecurityContextSwitch.withUserAndTenant("bumlux", tenantname, true, true, false, SecurityContextSwitch.runAs(SecurityContextSwitch.withUserAndTenant("bumlux", tenantname, true, true, false,
SpringEvalExpressions.SYSTEM_ROLE), () -> { SpringEvalExpressions.SYSTEM_ROLE), () -> {
systemManagement.getTenantMetadata(); systemManagement.getTenantMetadata();
@@ -171,9 +167,9 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
private void createDeletedTestArtifact(final byte[] random) { private void createDeletedTestArtifact(final byte[] random) {
final DistributionSet ds = testdataFactory.createDistributionSet("deleted garbage", true); final DistributionSet ds = testdataFactory.createDistributionSet("deleted garbage", true);
ds.getModules().stream().forEach(module -> { ds.getModules().forEach(module -> {
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file1", artifactManagement.create(
false, random.length)); new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file1", false, random.length));
softwareModuleManagement.delete(module.getId()); softwareModuleManagement.delete(module.getId());
}); });
} }

View File

@@ -66,7 +66,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means " @Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 0) })
public void nonExistingEntityAccessReturnsNotPresent() { public void nonExistingEntityAccessReturnsNotPresent() {
assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetFilterQueryManagement.getByName(NOT_EXIST_ID)).isNotPresent(); assertThat(targetFilterQueryManagement.getByName(NOT_EXIST_ID)).isNotPresent();
@@ -75,7 +76,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " @Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = TargetFilterQueryCreatedEvent.class, count = 1) }) @Expect(type = TargetFilterQueryCreatedEvent.class, count = 1) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() { public void entityQueriesReferringToNotExistingEntitiesThrowsException() {

View File

@@ -96,7 +96,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access react as specified on calls for non existing entities by means " @Description("Verifies that management get access react as specified on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
assertThat(targetManagement.getByControllerID(NOT_EXIST_ID)).isNotPresent(); assertThat(targetManagement.getByControllerID(NOT_EXIST_ID)).isNotPresent();
@@ -107,7 +108,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specified on calls for non existing entities " @Description("Verifies that management queries react as specified on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetTagCreatedEvent.class, count = 1) }) @Expect(type = TargetTagCreatedEvent.class, count = 1) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("A")); final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("A"));
@@ -182,7 +184,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that retrieving the target security is only permitted with the necessary permissions.") @Description("Ensures that retrieving the target security is only permitted with the necessary permissions.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1) })
void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception { void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception {
final Target createdTarget = targetManagement final Target createdTarget = targetManagement
.create(entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token")); .create(entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token"));
@@ -216,22 +219,10 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
assertThat(securityTokenWithoutPermission).isNull(); assertThat(securityTokenWithoutPermission).isNull();
} }
@Test
@Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists.")
@WithUser(tenantId = "tenantWhichDoesNotExists", allSpPermissions = true, autoCreateTenant = false)
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void createTargetForTenantWhichDoesNotExistThrowsTenantNotExistException() {
try {
targetManagement.create(entityFactory.target().create().controllerId("targetId123"));
fail("should not be possible as the tenant does not exist");
} catch (final TenantNotExistException e) {
// ok
}
}
@Test @Test
@Description("Verify that a target with same controller ID than another device cannot be created.") @Description("Verify that a target with same controller ID than another device cannot be created.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1) })
void createTargetThatViolatesUniqueConstraintFails() { void createTargetThatViolatesUniqueConstraintFails() {
targetManagement.create(entityFactory.target().create().controllerId("123")); targetManagement.create(entityFactory.target().create().controllerId("123"));
@@ -241,7 +232,9 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that a target with with invalid properties cannot be created or updated") @Description("Verify that a target with with invalid properties cannot be created or updated")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class) })
void createAndUpdateTargetWithInvalidFields() { void createAndUpdateTargetWithInvalidFields() {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
@@ -254,7 +247,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.") @Description("Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 4), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 4),
@Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 5) }) @Expect(type = TargetUpdatedEvent.class, count = 5) })
void assignAndUnassignTargetsToTag() { void assignAndUnassignTargetsToTag() {
@@ -294,8 +288,10 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that targets can deleted e.g. test all cascades") @Description("Ensures that targets can deleted e.g. test all cascades")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12), @ExpectEvents({
@Expect(type = TargetDeletedEvent.class, count = 12), @Expect(type = TargetUpdatedEvent.class, count = 6) }) @Expect(type = TargetCreatedEvent.class, count = 12),
@Expect(type = TargetDeletedEvent.class, count = 12),
@Expect(type = TargetUpdatedEvent.class, count = 6) })
void deleteAndCreateTargets() { void deleteAndCreateTargets() {
Target target = targetManagement.create(entityFactory.target().create().controllerId("targetId123")); Target target = targetManagement.create(entityFactory.target().create().controllerId("targetId123"));
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1); assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1);
@@ -322,12 +318,15 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Finds a target by given ID and checks if all data is in the response (including the data defined as lazy).") @Description("Finds a target by given ID and checks if all data is in the response (including the data defined as lazy).")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 2), @ExpectEvents({
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), // implicit lock
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5),
@Expect(type = ActionCreatedEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
@@ -389,7 +388,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Checks if the EntityAlreadyExistsException is thrown if the targets with the same controller ID are created twice.") @Description("Checks if the EntityAlreadyExistsException is thrown if the targets with the same controller ID are created twice.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 5) })
void createMultipleTargetsDuplicate() { void createMultipleTargetsDuplicate() {
testdataFactory.createTargets(5, "mySimpleTargs", "my simple targets"); testdataFactory.createTargets(5, "mySimpleTargs", "my simple targets");
try { try {
@@ -402,7 +402,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Checks if the EntityAlreadyExistsException is thrown if a single target with the same controller ID are created twice.") @Description("Checks if the EntityAlreadyExistsException is thrown if a single target with the same controller ID are created twice.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1) })
void createTargetDuplicate() { void createTargetDuplicate() {
targetManagement.create(entityFactory.target().create().controllerId("4711")); targetManagement.create(entityFactory.target().create().controllerId("4711"));
try { try {
@@ -415,7 +416,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@WithUser(allSpPermissions = true) @WithUser(allSpPermissions = true)
@Description("Creates and updates a target and verifies the changes in the repository.") @Description("Creates and updates a target and verifies the changes in the repository.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 1) })
void singleTargetIsInsertedIntoRepo() throws Exception { void singleTargetIsInsertedIntoRepo() throws Exception {
@@ -452,7 +454,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@WithUser(allSpPermissions = true) @WithUser(allSpPermissions = true)
@Description("Create multiple targets as bulk operation and delete them in bulk.") @Description("Create multiple targets as bulk operation and delete them in bulk.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 101), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 101),
@Expect(type = TargetUpdatedEvent.class, count = 100), @Expect(type = TargetUpdatedEvent.class, count = 100),
@Expect(type = TargetDeletedEvent.class, count = 51) }) @Expect(type = TargetDeletedEvent.class, count = 51) })
void bulkTargetCreationAndDelete() { void bulkTargetCreationAndDelete() {
@@ -518,7 +521,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests the assignment of tags to the a single target.") @Description("Tests the assignment of tags to the a single target.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetTagCreatedEvent.class, count = 7), @Expect(type = TargetTagCreatedEvent.class, count = 7),
@Expect(type = TargetUpdatedEvent.class, count = 7) }) @Expect(type = TargetUpdatedEvent.class, count = 7) })
void targetTagAssignment() { void targetTagAssignment() {
@@ -550,7 +554,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests the assignment of tags to multiple targets.") @Description("Tests the assignment of tags to multiple targets.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 50), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 50),
@Expect(type = TargetTagCreatedEvent.class, count = 4), @Expect(type = TargetTagCreatedEvent.class, count = 4),
@Expect(type = TargetUpdatedEvent.class, count = 80) }) @Expect(type = TargetUpdatedEvent.class, count = 80) })
void targetTagBulkAssignments() { void targetTagBulkAssignments() {
@@ -619,7 +624,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests the unassigment of tags to multiple targets.") @Description("Tests the unassigment of tags to multiple targets.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 3), @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 3),
@Expect(type = TargetCreatedEvent.class, count = 109), @Expect(type = TargetCreatedEvent.class, count = 109),
@Expect(type = TargetUpdatedEvent.class, count = 227) }) @Expect(type = TargetUpdatedEvent.class, count = 227) })
void targetTagBulkUnassignments() { void targetTagBulkUnassignments() {
@@ -677,7 +683,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Test that NO TAG functionality which gives all targets with no tag assigned.") @Description("Test that NO TAG functionality which gives all targets with no tag assigned.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 50), @Expect(type = TargetCreatedEvent.class, count = 50),
@Expect(type = TargetUpdatedEvent.class, count = 25) }) @Expect(type = TargetUpdatedEvent.class, count = 25) })
void findTargetsWithNoTag() { void findTargetsWithNoTag() {
@@ -698,7 +705,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests the a target can be read with only the read target permission") @Description("Tests the a target can be read with only the read target permission")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
void targetCanBeReadWithOnlyReadTargetPermission() throws Exception { void targetCanBeReadWithOnlyReadTargetPermission() throws Exception {
final String knownTargetControllerId = "readTarget"; final String knownTargetControllerId = "readTarget";
@@ -735,7 +743,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that the find all targets by ids method contains the entities that we are looking for") @Description("Verify that the find all targets by ids method contains the entities that we are looking for")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 12) })
void verifyFindTargetAllById() { void verifyFindTargetAllById() {
final List<Long> searchIds = Arrays.asList(testdataFactory.createTarget("target-4").getId(), final List<Long> searchIds = Arrays.asList(testdataFactory.createTarget("target-4").getId(),
testdataFactory.createTarget("target-5").getId(), testdataFactory.createTarget("target-6").getId()); testdataFactory.createTarget("target-5").getId(), testdataFactory.createTarget("target-6").getId());
@@ -933,9 +942,11 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@WithUser(allSpPermissions = true) @WithUser(allSpPermissions = true)
@Description("Tests the assignment of types to multiple targets.") @Description("Tests the assignment of types to multiple targets.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 20), @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 20),
@Expect(type = TargetTypeCreatedEvent.class, count = 2), @Expect(type = TargetTypeCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 29), @Expect(type = TargetDeletedEvent.class, count = 1) }) @Expect(type = TargetUpdatedEvent.class, count = 29),
@Expect(type = TargetDeletedEvent.class, count = 1) })
void targetTypeBulkAssignments() { void targetTypeBulkAssignments() {
final List<Target> typeATargets = testdataFactory.createTargets(10, "typeATargets", "first description"); final List<Target> typeATargets = testdataFactory.createTargets(10, "typeATargets", "first description");
final List<Target> typeBTargets = testdataFactory.createTargets(10, "typeBTargets", "first description"); final List<Target> typeBTargets = testdataFactory.createTargets(10, "typeBTargets", "first description");

View File

@@ -90,7 +90,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means " + @Description("Verifies that management get access reacts as specfied on calls for non existing entities by means " +
"of Optional not present.") "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
assertThat(targetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent(); assertThat(targetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
assertThat(targetTagManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(targetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
@@ -99,7 +100,9 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specfied on calls for non existing entities " + @Description("Verifies that management queries react as specfied on calls for non existing entities " +
" by means of throwing EntityNotFoundException.") " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class), @Expect(type = TargetTagUpdatedEvent.class) }) @ExpectEvents({
@Expect(type = DistributionSetTagUpdatedEvent.class),
@Expect(type = TargetTagUpdatedEvent.class) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> targetTagManagement.delete(NOT_EXIST_ID), "TargetTag"); verifyThrownExceptionBy(() -> targetTagManagement.delete(NOT_EXIST_ID), "TargetTag");
verifyThrownExceptionBy(() -> targetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)), "TargetTag"); verifyThrownExceptionBy(() -> targetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)), "TargetTag");

View File

@@ -43,7 +43,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management get access react as specified on calls for non existing entities by means " @Description("Verifies that management get access react as specified on calls for non existing entities by means "
+ "of Optional not present.") + "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetTypeCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() { void nonExistingEntityAccessReturnsNotPresent() {
assertThat(targetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(targetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent(); assertThat(targetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
@@ -52,7 +53,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verifies that management queries react as specified on calls for non existing entities " @Description("Verifies that management queries react as specified on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = TargetTypeUpdatedEvent.class) }) @ExpectEvents({
@Expect(type = TargetTypeUpdatedEvent.class) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> targetTypeManagement.delete(NOT_EXIST_IDL), "TargetType"); verifyThrownExceptionBy(() -> targetTypeManagement.delete(NOT_EXIST_IDL), "TargetType");
verifyThrownExceptionBy(() -> targetTypeManagement.update(entityFactory.targetType().update(NOT_EXIST_IDL)), verifyThrownExceptionBy(() -> targetTypeManagement.update(entityFactory.targetType().update(NOT_EXIST_IDL)),

View File

@@ -28,7 +28,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
public class SecurityContextSwitch { public class SecurityContextSwitch {
public static final String DEFAULT_TENANT = "default"; public static final String DEFAULT_TENANT = "DEFAULT";
private static final WithUser PRIVILEDGED_USER = private static final WithUser PRIVILEDGED_USER =
createWithUser("bumlux", DEFAULT_TENANT, false, true, false, "ROLE_CONTROLLER", "ROLE_SYSTEM_CODE"); createWithUser("bumlux", DEFAULT_TENANT, false, true, false, "ROLE_CONTROLLER", "ROLE_SYSTEM_CODE");

View File

@@ -81,6 +81,7 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
/** /**
* Data generator utility for tests. * Data generator utility for tests.
@@ -314,7 +315,7 @@ public class TestdataFactory {
return distributionSetManagement.create( return distributionSetManagement.create(
entityFactory.distributionSet().create() entityFactory.distributionSet().create()
.type(findOrCreateDefaultTestDsType()) .type(findOrCreateDefaultTestDsType())
.name(prefix == null || prefix.isEmpty() ? "DS" : prefix) .name(ObjectUtils.isEmpty(prefix) ? "DS" : prefix)
.version(version) .version(version)
.description(randomDescriptionShort()) .description(randomDescriptionShort())
.modules(Arrays.asList(osMod.getId(), runtimeMod.getId(), appMod.getId())) .modules(Arrays.asList(osMod.getId(), runtimeMod.getId(), appMod.getId()))
@@ -322,8 +323,7 @@ public class TestdataFactory {
} }
/** /**
* Adds {@link SoftwareModuleMetadata} to every module of given * Adds {@link SoftwareModuleMetadata} to every module of given {@link DistributionSet}.
* {@link DistributionSet}.
* *
* {@link #VISIBLE_SM_MD_VALUE}, {@link #VISIBLE_SM_MD_KEY} with * {@link #VISIBLE_SM_MD_VALUE}, {@link #VISIBLE_SM_MD_KEY} with
* {@link SoftwareModuleMetadata#isTargetVisible()} and * {@link SoftwareModuleMetadata#isTargetVisible()} and

View File

@@ -48,7 +48,7 @@ public @interface WithUser {
* *
* @return test tenant id * @return test tenant id
*/ */
String tenantId() default "default"; String tenantId() default "DEFAULT";
/** /**
* Should tenant auto created. * Should tenant auto created.