New event strategy (#380)

* Add notfication overview for remote events

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Refactor css for notification button

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Remove todo

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* - Style notfication button (css) 
- Add i18n message keys
- Add switch slider for auto refresh event

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Insert Label in MenuItem for displaying occurred events

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* - Style notfication button (css) 
- Add i18n message keys
- Add switch slider for auto refresh event
- Insert Label in MenuItem for displaying occurred events

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Solve merge conflicts and add menu item counter

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* CSS refactor

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Adapt JUnit test for events, because constructor is changed

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Skip delete event

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* - Insert Id for notification menu

- Enable push mechanism for target and ds tag and add notfications

- Fix several typos

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Add update ui events for tags and add different id's for menue item

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Insert push for SoftwareModule

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Set button enablement

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Add Software module update push event
Add unit test software module push events
Adapt test for software push event

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Close window and set pop id
Update the target table to set the new icon

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* - several code improvements
- Correct license header

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Update vaadin version
Rename the base entity and redefine constructors
unread counter was not correct

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Closebox of notificationButton is invisible: 
Insert height for HorizontalLayout of NotificationUnreadButton

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Add software modules to the new event types

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Introduce animation in unreadNotificationButton

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Fix close  on safari

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add publish events direct to the tag entities.


Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
Melanie Retter
2016-12-19 16:05:23 +01:00
committed by Kai Zimmermann
parent ccc23bf634
commit 2dec35915c
115 changed files with 1891 additions and 726 deletions

View File

@@ -29,6 +29,12 @@ public class RemoteIdEventTest extends AbstractRemoteEventTest {
private static final long ENTITY_ID = 1L;
private static String TENANT = "tenant";
private static String ENTIY_CLASS = "EntityClass";
private static String NODE = "Node";
@Test
@Description("Verifies that the is ds id correct reloaded")
public void testDistributionSetDeletedEvent() {
@@ -53,30 +59,43 @@ public class RemoteIdEventTest extends AbstractRemoteEventTest {
assertAndCreateRemoteEvent(TargetTagDeletedEvent.class);
}
@Test
@Description("Verifies that the software module id is correct reloaded")
public void testSoftwareModuleDeletedEvent() {
assertAndCreateRemoteEvent(SoftwareModuleDeletedEvent.class);
}
protected void assertAndCreateRemoteEvent(final Class<? extends RemoteIdEvent> eventType) {
final Constructor<?> constructor = Arrays.stream(eventType.getDeclaredConstructors())
.filter(con -> con.getParameterCount() == 3).findAny()
.filter(con -> con.getParameterCount() == 4).findAny()
.orElseThrow(() -> new IllegalArgumentException("Given event is not RemoteIdEvent compatible"));
try {
final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance("tenant", ENTITY_ID, "Node");
assertEntity(ENTITY_ID, event);
final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance(TENANT, ENTITY_ID, ENTIY_CLASS, NODE);
assertEntity(event);
} catch (final ReflectiveOperationException e) {
fail("Exception should not happen " + e.getMessage());
}
}
protected RemoteIdEvent assertEntity(final long id, final RemoteIdEvent event) {
assertThat(event.getEntityId()).isSameAs(id);
protected RemoteIdEvent assertEntity(final RemoteIdEvent event) {
assertThat(event.getEntityId()).isSameAs(ENTITY_ID);
RemoteIdEvent underTestCreatedEvent = (RemoteIdEvent) createProtoStuffEvent(event);
assertThat(underTestCreatedEvent.getEntityId()).isEqualTo(id);
assertDeserializeEvent(underTestCreatedEvent);
underTestCreatedEvent = (RemoteIdEvent) createJacksonEvent(event);
assertThat(underTestCreatedEvent.getEntityId()).isEqualTo(id);
assertDeserializeEvent(underTestCreatedEvent);
return underTestCreatedEvent;
}
private void assertDeserializeEvent(final RemoteIdEvent underTestCreatedEvent) {
assertThat(underTestCreatedEvent.getEntityId()).isEqualTo(ENTITY_ID);
assertThat(underTestCreatedEvent.getTenant()).isEqualTo(TENANT);
assertThat(underTestCreatedEvent.getEntityClass()).isEqualTo(ENTIY_CLASS);
assertThat(underTestCreatedEvent.getOriginService()).isEqualTo(NODE);
}
}

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.event.remote.entity;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.junit.Test;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
/**
* Test the remote entity events.
*/
@Features("Component Tests - Repository")
@Stories("Test SoftwareModuleCreatedEvent, SoftwareModuleUpdatedEvent")
public class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest<SoftwareModule> {
@Test
@Description("Verifies that the software module entity reloading by remote created event works")
public void testTargetCreatedEvent() {
assertAndCreateRemoteEvent(SoftwareModuleCreatedEvent.class);
}
@Test
@Description("Verifies that the software module entity reloading by remote updated event works")
public void testTargetUpdatedEvent() {
assertAndCreateRemoteEvent(SoftwareModuleUpdatedEvent.class);
}
@Override
protected SoftwareModule createEntity() {
return testdataFactory.createSoftwareModuleApp();
}
}

View File

@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEv
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
@@ -48,7 +49,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1) })
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
public void controllerAddsActionStatus() {
final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget();

View File

@@ -31,6 +31,7 @@ import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
@@ -260,7 +261,8 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = TargetCreatedEvent.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 = SoftwareModuleCreatedEvent.class, count = 6) })
public void findTargetByControllerIDWithDetails() {
final DistributionSet set = testdataFactory.createDistributionSet("test");
final DistributionSet set2 = testdataFactory.createDistributionSet("test2");

View File

@@ -16,13 +16,17 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.hawkbit.repository.event.TenantAwareEvent;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.event.RepositoryEntityEventTest.RepositoryTestConfiguration;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.fest.assertions.api.Assertions;
import org.junit.Before;
@@ -110,6 +114,42 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
assertThat(dsDeletedEvent.getEntityId()).isEqualTo(createDistributionSet.getId());
}
@Test
@Description("Verifies that the software module created event is published when a software module has been created")
public void softwareModuleCreatedEventIsPublished() throws InterruptedException {
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
final SoftwareModuleCreatedEvent softwareModuleCreatedEvent = eventListener
.waitForEvent(SoftwareModuleCreatedEvent.class, 1, TimeUnit.SECONDS);
assertThat(softwareModuleCreatedEvent).isNotNull();
assertThat(softwareModuleCreatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId());
}
@Test
@Description("Verifies that the software module update event is published when a software module has been updated")
public void softwareModuleUpdateEventIsPublished() throws InterruptedException {
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
softwareManagement
.updateSoftwareModule(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener
.waitForEvent(SoftwareModuleUpdatedEvent.class, 1, TimeUnit.SECONDS);
assertThat(softwareModuleUpdatedEvent).isNotNull();
assertThat(softwareModuleUpdatedEvent.getEntity().getId()).isEqualTo(softwareModule.getId());
}
@Test
@Description("Verifies that the software module deleted event is published when a software module has been deleted")
public void softwareModuleDeletedEventIsPublished() throws InterruptedException {
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
softwareManagement.deleteSoftwareModule(softwareModule.getId());
final SoftwareModuleDeletedEvent softwareModuleDeletedEvent = eventListener
.waitForEvent(SoftwareModuleDeletedEvent.class, 1, TimeUnit.SECONDS);
assertThat(softwareModuleDeletedEvent).isNotNull();
assertThat(softwareModuleDeletedEvent.getEntityId()).isEqualTo(softwareModule.getId());
}
public static class RepositoryTestConfiguration {
@Bean