Fix NPE push Management UI on events (#543)
* NEP check on event.getEntity . Performance optimization on DS table. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix event tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * used method reference. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -18,6 +18,8 @@ public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionS
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private boolean complete;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@@ -32,8 +34,21 @@ public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionS
|
||||
* Distribution Set
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
* @param complete
|
||||
* <code>true</code> if {@link DistributionSet} is after the
|
||||
* update {@link DistributionSet#isComplete()}
|
||||
*/
|
||||
public DistributionSetUpdatedEvent(final DistributionSet ds, final String applicationId) {
|
||||
public DistributionSetUpdatedEvent(final DistributionSet ds, final String applicationId, final boolean complete) {
|
||||
super(ds, applicationId);
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if {@link DistributionSet} is after the update
|
||||
* {@link DistributionSet#isComplete()}
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
||||
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||
|
||||
publishEventWithEventPublisher(
|
||||
new DistributionSetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
new DistributionSetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId(), complete));
|
||||
|
||||
if (isSoftDeleted(descriptorEvent)) {
|
||||
publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass().getName(),
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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.DistributionSet;
|
||||
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 DistributionSetCreatedEvent")
|
||||
public class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTest<DistributionSet> {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the distribution set entity reloading by remote created event works")
|
||||
public void testDistributionSetCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetCreatedEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,14 +19,8 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
* Test the remote entity events.
|
||||
*/
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Test DistributionSetCreatedEvent and DistributionSetUpdateEvent")
|
||||
public class DistributionSetEventTest extends AbstractRemoteEntityEventTest<DistributionSet> {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the distribution set entity reloading by remote created event works")
|
||||
public void testDistributionSetCreatedEvent() {
|
||||
assertAndCreateRemoteEvent(DistributionSetCreatedEvent.class);
|
||||
}
|
||||
@Stories("Test DistributionSetUpdateEvent")
|
||||
public class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest<DistributionSet> {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the distribution set entity reloading by remote updated event works")
|
||||
@@ -34,6 +28,13 @@ public class DistributionSetEventTest extends AbstractRemoteEntityEventTest<Dist
|
||||
assertAndCreateRemoteEvent(DistributionSetUpdatedEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteEntityEvent<?> createRemoteEvent(final DistributionSet baseEntity,
|
||||
final Class<? extends RemoteEntityEvent<?>> eventType) {
|
||||
|
||||
return new DistributionSetUpdatedEvent(baseEntity, "1", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
||||
Reference in New Issue
Block a user