Feature add missing entity events (#640)
* introduce CRD event interfaces and add missing events for entities Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * extend EntityIdEvent by TenantAwareEvent Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * add tests for additional events and skip test preperation events Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * add missing expected events to tests Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * add target filter query CUD events Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * fix order imports Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * fix javadoc link Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * add neccessary EventType mapping for serialization Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.entitiy;
|
||||
|
||||
/**
|
||||
* Marker interface to indicate event has created a newly entity.
|
||||
*/
|
||||
public interface EntityCreatedEvent extends EntityIdEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.entitiy;
|
||||
|
||||
/**
|
||||
* Marker interface to indicate event has deleted an entity.
|
||||
*/
|
||||
public interface EntityDeletedEvent extends EntityIdEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.entitiy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.TenantAwareEvent;
|
||||
|
||||
/**
|
||||
* Interface to indicate an entity event which contains at least an entity id.
|
||||
*/
|
||||
public interface EntityIdEvent extends TenantAwareEvent {
|
||||
|
||||
/**
|
||||
* @return the class of the entity of this event.
|
||||
*/
|
||||
String getEntityClass();
|
||||
|
||||
/**
|
||||
* @return the ID of the entity of this event.
|
||||
*/
|
||||
Long getEntityId();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.entitiy;
|
||||
|
||||
/**
|
||||
* Marker interface to indicate event has updated an entity.
|
||||
*/
|
||||
public interface EntityUpdatedEvent extends EntityIdEvent {
|
||||
|
||||
}
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
|
||||
/**
|
||||
* Defines the remote event for deletion of {@link DistributionSet}.
|
||||
*/
|
||||
public class DistributionSetDeletedEvent extends RemoteIdEvent {
|
||||
public class DistributionSetDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* Defines the the remote event of delete a {@link DistributionSetTag}.
|
||||
*/
|
||||
public class DistributionSetTagDeletedEvent extends RemoteIdEvent {
|
||||
public class DistributionSetTagDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link DistributionSetType}.
|
||||
*/
|
||||
public class DistributionSetTypeDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public DistributionSetTypeDeletedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for json serialization.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entityId
|
||||
* the entity id
|
||||
* @param entityClass
|
||||
* the entity class
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public DistributionSetTypeDeletedEvent(final String tenant, final Long entityId, final String entityClass,
|
||||
final String applicationId) {
|
||||
super(entityId, tenant, entityClass, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link Rollout}.
|
||||
*/
|
||||
public class RolloutDeletedEvent extends RemoteIdEvent {
|
||||
public class RolloutDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link RolloutGroup}.
|
||||
*/
|
||||
public class RolloutGroupDeletedEvent extends RemoteIdEvent {
|
||||
public class RolloutGroupDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link SoftwareModule}.
|
||||
*/
|
||||
public class SoftwareModuleDeletedEvent extends RemoteIdEvent {
|
||||
public class SoftwareModuleDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link SoftwareModuleType}.
|
||||
*/
|
||||
public class SoftwareModuleTypeDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public SoftwareModuleTypeDeletedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for json serialization.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entityId
|
||||
* the entity id
|
||||
* @param entityClass
|
||||
* the entity class
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public SoftwareModuleTypeDeletedEvent(final String tenant, final Long entityId, final String entityClass,
|
||||
final String applicationId) {
|
||||
super(entityId, tenant, entityClass, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link Target}.
|
||||
*/
|
||||
public class TargetDeletedEvent extends RemoteIdEvent {
|
||||
public class TargetDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 2L;
|
||||
private String controllerId;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link TargetFilterQuery}.
|
||||
*/
|
||||
public class TargetFilterQueryDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetFilterQueryDeletedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entityId
|
||||
* the entity id
|
||||
* @param entityClass
|
||||
* the entity class
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public TargetFilterQueryDeletedEvent(final String tenant, final Long entityId, final String entityClass,
|
||||
final String applicationId) {
|
||||
super(entityId, tenant, entityClass, applicationId);
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* Defines the remote event of delete a {@link TargetTag}.
|
||||
*
|
||||
*/
|
||||
public class TargetTagDeletedEvent extends RemoteIdEvent {
|
||||
public class TargetTagDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link Action}.
|
||||
*/
|
||||
public class ActionCreatedEvent extends AbstractActionEvent {
|
||||
public class ActionCreatedEvent extends AbstractActionEvent implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* Defines the remote event of updated a {@link Action}.
|
||||
*/
|
||||
public class ActionUpdatedEvent extends AbstractActionEvent {
|
||||
public class ActionUpdatedEvent extends AbstractActionEvent implements EntityUpdatedEvent {
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
|
||||
/**
|
||||
* Defines the the remote of creating a new {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetCreatedEvent extends RemoteEntityEvent<DistributionSet> {
|
||||
public class DistributionSetCreatedEvent extends RemoteEntityEvent<DistributionSet> implements EntityCreatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
@@ -15,7 +16,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
* {@link DistributionSetTag}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagCreatedEvent extends RemoteEntityEvent<DistributionSetTag> {
|
||||
public class DistributionSetTagCreatedEvent extends RemoteEntityEvent<DistributionSetTag>
|
||||
implements EntityCreatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,13 +8,15 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* Defines the remote event for update a {@link DistributionSetTag}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagUpdatedEvent extends RemoteEntityEvent<DistributionSetTag> {
|
||||
public class DistributionSetTagUpdatedEvent extends RemoteEntityEvent<DistributionSetTag>
|
||||
implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link DistributionSetType}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTypeCreatedEvent extends RemoteEntityEvent<DistributionSetType>
|
||||
implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public DistributionSetTypeCreatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* the DistributionSetType
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public DistributionSetTypeCreatedEvent(final DistributionSetType baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link SoftwareModuleType}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTypeUpdatedEvent extends RemoteEntityEvent<DistributionSetType>
|
||||
implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public DistributionSetTypeUpdatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* DistributionSetType
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public DistributionSetTypeUpdatedEvent(final DistributionSetType baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionSet> {
|
||||
public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionSet> implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link Rollout}.
|
||||
*
|
||||
*/
|
||||
public class RolloutCreatedEvent extends RemoteEntityEvent<Rollout> implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public RolloutCreatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* the Rollout
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public RolloutCreatedEvent(final Rollout baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
|
||||
/**
|
||||
@@ -15,7 +16,7 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
* has been created for a specific rollout.
|
||||
*
|
||||
*/
|
||||
public class RolloutGroupCreatedEvent extends AbstractRolloutGroupEvent {
|
||||
public class RolloutGroupCreatedEvent extends AbstractRolloutGroupEvent implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
|
||||
/**
|
||||
* Defines the remote event of updated a {@link RolloutGroup}.
|
||||
*/
|
||||
public class RolloutGroupUpdatedEvent extends AbstractRolloutGroupEvent {
|
||||
public class RolloutGroupUpdatedEvent extends AbstractRolloutGroupEvent implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Defines the remote event of updated a {@link Rollout}.
|
||||
*/
|
||||
public class RolloutUpdatedEvent extends RemoteEntityEvent<Rollout> {
|
||||
public class RolloutUpdatedEvent extends RemoteEntityEvent<Rollout> implements EntityUpdatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link SoftwareModule}.
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleCreatedEvent extends RemoteEntityEvent<SoftwareModule> {
|
||||
public class SoftwareModuleCreatedEvent extends RemoteEntityEvent<SoftwareModule> implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link SoftwareModuleType}.
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleTypeCreatedEvent extends RemoteEntityEvent<SoftwareModuleType>
|
||||
implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public SoftwareModuleTypeCreatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* the SoftwareModuleType
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public SoftwareModuleTypeCreatedEvent(final SoftwareModuleType baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link SoftwareModuleType}.
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleTypeUpdatedEvent extends RemoteEntityEvent<SoftwareModuleType> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public SoftwareModuleTypeUpdatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* SoftwareModuleType entity
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public SoftwareModuleTypeUpdatedEvent(final SoftwareModuleType baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link SoftwareModule}.
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleUpdatedEvent extends RemoteEntityEvent<SoftwareModule> {
|
||||
public class SoftwareModuleUpdatedEvent extends RemoteEntityEvent<SoftwareModule> implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link Target}.
|
||||
*
|
||||
*/
|
||||
public class TargetCreatedEvent extends RemoteEntityEvent<Target> {
|
||||
public class TargetCreatedEvent extends RemoteEntityEvent<Target> implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link TargetFilterQuery}.
|
||||
*
|
||||
*/
|
||||
public class TargetFilterQueryCreatedEvent extends RemoteEntityEvent<TargetFilterQuery> implements EntityCreatedEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetFilterQueryCreatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* the TargetFilterQuery
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public TargetFilterQueryCreatedEvent(final TargetFilterQuery baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link TargetFilterQuery}.
|
||||
*
|
||||
*/
|
||||
public class TargetFilterQueryUpdatedEvent extends RemoteEntityEvent<TargetFilterQuery> implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TargetFilterQueryUpdatedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* TargetFilterQuery entity
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public TargetFilterQueryUpdatedEvent(final TargetFilterQuery baseEntity, final String applicationId) {
|
||||
super(baseEntity, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* Defines the remote event for the creation of a new {@link TargetTag}.
|
||||
*
|
||||
*/
|
||||
public class TargetTagCreatedEvent extends RemoteEntityEvent<TargetTag> {
|
||||
public class TargetTagCreatedEvent extends RemoteEntityEvent<TargetTag> implements EntityCreatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link TargetTag}.
|
||||
*
|
||||
*/
|
||||
public class TargetTagUpdatedEvent extends RemoteEntityEvent<TargetTag> {
|
||||
public class TargetTagUpdatedEvent extends RemoteEntityEvent<TargetTag> implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.entitiy.EntityUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
* Defines the remote event for updating a {@link Target}.
|
||||
*
|
||||
*/
|
||||
public class TargetUpdatedEvent extends RemoteEntityEvent<Target> {
|
||||
public class TargetUpdatedEvent extends RemoteEntityEvent<Target> implements EntityUpdatedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -14,12 +14,15 @@ import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.RolloutGroupDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleTypeDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetFilterQueryDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetTagDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
|
||||
@@ -28,13 +31,20 @@ import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignment
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeUpdatedEvent;
|
||||
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.TargetFilterQueryCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
||||
@@ -101,6 +111,23 @@ public class EventType {
|
||||
TYPES.put(24, TargetPollEvent.class);
|
||||
TYPES.put(25, RolloutDeletedEvent.class);
|
||||
TYPES.put(26, RolloutGroupDeletedEvent.class);
|
||||
TYPES.put(27, RolloutCreatedEvent.class);
|
||||
|
||||
// distribution set type
|
||||
TYPES.put(28, DistributionSetTypeCreatedEvent.class);
|
||||
TYPES.put(29, DistributionSetTypeUpdatedEvent.class);
|
||||
TYPES.put(30, DistributionSetTypeDeletedEvent.class);
|
||||
|
||||
// software module type
|
||||
TYPES.put(31, SoftwareModuleTypeCreatedEvent.class);
|
||||
TYPES.put(32, SoftwareModuleTypeUpdatedEvent.class);
|
||||
TYPES.put(33, SoftwareModuleTypeDeletedEvent.class);
|
||||
|
||||
// target filter query
|
||||
TYPES.put(34, TargetFilterQueryCreatedEvent.class);
|
||||
TYPES.put(35, TargetFilterQueryUpdatedEvent.class);
|
||||
TYPES.put(36, TargetFilterQueryDeletedEvent.class);
|
||||
|
||||
}
|
||||
|
||||
private int value;
|
||||
|
||||
@@ -25,11 +25,16 @@ import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -46,7 +51,7 @@ import org.springframework.util.CollectionUtils;
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSetType extends AbstractJpaNamedEntity implements DistributionSetType {
|
||||
public class JpaDistributionSetType extends AbstractJpaNamedEntity implements DistributionSetType, EventAwareEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@CascadeOnDelete
|
||||
@@ -230,4 +235,21 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
|
||||
return "DistributionSetType [key=" + key + ", isDeleted()=" + isDeleted() + ", getId()=" + getId() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||
new DistributionSetTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||
new DistributionSetTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetDeletedEvent(getTenant(),
|
||||
getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
@@ -230,7 +231,8 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
|
||||
|
||||
@Override
|
||||
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||
// there is no rollout creation event
|
||||
EventPublisherHolder.getInstance().getEventPublisher()
|
||||
.publishEvent(new RolloutCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,12 @@ import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleTypeDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
|
||||
/**
|
||||
* Type of a software modules.
|
||||
@@ -32,7 +37,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements SoftwareModuleType {
|
||||
public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements SoftwareModuleType, EventAwareEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "type_key", nullable = false, length = SoftwareModuleType.KEY_MAX_SIZE)
|
||||
@@ -138,4 +143,22 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
|
||||
public void setKey(final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||
new SoftwareModuleTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||
new SoftwareModuleTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleTypeDeletedEvent(
|
||||
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,14 @@ import javax.persistence.UniqueConstraint;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetFilterQueryDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
|
||||
/**
|
||||
* Stored target filter.
|
||||
@@ -34,7 +39,8 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery {
|
||||
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity
|
||||
implements TargetFilterQuery, EventAwareEntity {
|
||||
private static final long serialVersionUID = 7493966984413479089L;
|
||||
|
||||
@Column(name = "name", length = NamedEntity.NAME_MAX_SIZE, nullable = false)
|
||||
@@ -98,4 +104,22 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity imple
|
||||
public void setAutoAssignDistributionSet(final JpaDistributionSet distributionSet) {
|
||||
this.autoAssignDistributionSet = distributionSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||
new TargetFilterQueryCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||
new TargetFilterQueryUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetFilterQueryDeletedEvent(
|
||||
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
@@ -19,6 +15,7 @@ import javax.validation.ConstraintViolationException;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
@@ -31,6 +28,10 @@ import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Step;
|
||||
@@ -56,7 +57,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Test
|
||||
@Description("Verifies that management queries react as specfied on calls for non existing entities "
|
||||
+ " 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) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(NOT_EXIST_IDL,
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
||||
@@ -21,6 +20,8 @@ import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
@@ -47,24 +48,26 @@ public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = RolloutUpdatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 10) })
|
||||
@Expect(type = RolloutUpdatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 10),
|
||||
@Expect(type = RolloutCreatedEvent.class, count = 1) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
testdataFactory.createRollout("xxx");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countByRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countTargetsOfRolloutsGroup(NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, NOT_EXIST_IDL),
|
||||
"Rollout");
|
||||
verifyThrownExceptionBy(
|
||||
() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findAllTargetsOfRolloutGroupWithActionStatus(PAGE, NOT_EXIST_IDL),
|
||||
() -> rolloutGroupManagement.findAllTargetsOfRolloutGroupWithActionStatus(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
verifyThrownExceptionBy(
|
||||
() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"RolloutGroup");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -33,6 +30,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.RolloutCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
||||
@@ -71,6 +69,9 @@ import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Step;
|
||||
@@ -137,7 +138,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = RolloutUpdatedEvent.class, count = 1),
|
||||
@Expect(type = RolloutUpdatedEvent.class, count = 1), @Expect(type = RolloutCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 10) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
testdataFactory.createRollout("xxx");
|
||||
@@ -1419,7 +1420,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = RolloutGroupCreatedEvent.class, count = 5),
|
||||
@Expect(type = RolloutGroupDeletedEvent.class, count = 5),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5) })
|
||||
@Expect(type = RolloutGroupUpdatedEvent.class, count = 5),
|
||||
@Expect(type = RolloutCreatedEvent.class, count = 1) })
|
||||
public void deleteRolloutWhichHasNeverStartedIsHardDeleted() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
@@ -1450,7 +1452,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = RolloutGroupCreatedEvent.class, count = 5),
|
||||
@Expect(type = RolloutGroupDeletedEvent.class, count = 5),
|
||||
@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) })
|
||||
public void deleteRolloutWhichHasBeenStartedBeforeIsSoftDeleted() {
|
||||
final int amountTargetsForRollout = 10;
|
||||
final int amountOtherTargets = 15;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -23,6 +22,7 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
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.TargetFilterQueryCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -34,6 +34,8 @@ import org.junit.Test;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
@@ -59,38 +61,38 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verifies that management queries react as specfied on calls for non existing entities "
|
||||
+ " by means of throwing EntityNotFoundException.")
|
||||
@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) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("test filter").query("name==PendingTargets001"));
|
||||
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL), "TargetFilterQuery");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement
|
||||
.update(entityFactory.targetFilterQuery().update(NOT_EXIST_IDL)),
|
||||
() -> targetFilterQueryManagement.update(entityFactory.targetFilterQuery().update(NOT_EXIST_IDL)),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement
|
||||
.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.updateAutoAssignDS(1234L, set.getId()),
|
||||
() -> targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.updateAutoAssignDS(1234L, set.getId()),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement
|
||||
.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test creation of target filter query.")
|
||||
public void createTargetFilterQuery() {
|
||||
final String filterName = "new target filter";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery,
|
||||
targetFilterQueryManagement.getByName(filterName).get());
|
||||
}
|
||||
@@ -99,8 +101,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test searching a target filter query.")
|
||||
public void searchTargetFilterQuery() {
|
||||
final String filterName = "targetFilterQueryName";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002"));
|
||||
@@ -115,8 +117,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test searching a target filter query with an invalid filter.")
|
||||
public void searchTargetFilterQueryInvalidField() {
|
||||
// Should throw an exception
|
||||
targetFilterQueryManagement.findByRsql(new PageRequest(0, 10), "unknownField==testValue")
|
||||
.getContent();
|
||||
targetFilterQueryManagement.findByRsql(new PageRequest(0, 10), "unknownField==testValue").getContent();
|
||||
|
||||
}
|
||||
|
||||
@@ -124,8 +125,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Checks if the EntityAlreadyExistsException is thrown if a targetfilterquery with the same name are created more than once.")
|
||||
public void createDuplicateTargetFilterQuery() {
|
||||
final String filterName = "new target filter duplicate";
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
try {
|
||||
targetFilterQueryManagement.create(
|
||||
@@ -140,8 +141,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test deletion of target filter query.")
|
||||
public void deleteTargetFilterQuery() {
|
||||
final String filterName = "delete_target_filter_query";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
targetFilterQueryManagement.delete(targetFilterQuery.getId());
|
||||
assertFalse("Returns null as the target filter is deleted",
|
||||
targetFilterQueryManagement.get(targetFilterQuery.getId()).isPresent());
|
||||
@@ -152,12 +153,12 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test updation of target filter query.")
|
||||
public void updateTargetFilterQuery() {
|
||||
final String filterName = "target_filter_01";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final String newQuery = "status==UNKNOWN";
|
||||
targetFilterQueryManagement.update(
|
||||
entityFactory.targetFilterQuery().update(targetFilterQuery.getId()).query(newQuery));
|
||||
targetFilterQueryManagement
|
||||
.update(entityFactory.targetFilterQuery().update(targetFilterQuery.getId()).query(newQuery));
|
||||
assertEquals("Returns updated target filter query", newQuery,
|
||||
targetFilterQueryManagement.getByName(filterName).get().getQuery());
|
||||
|
||||
@@ -167,13 +168,12 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test assigning a distribution set")
|
||||
public void assignDistributionSet() {
|
||||
final String filterName = "target_filter_02";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(),
|
||||
distributionSet.getId());
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), distributionSet.getId());
|
||||
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
|
||||
@@ -185,13 +185,12 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test removing distribution set while it has a relation to a target filter query")
|
||||
public void removeAssignDistributionSet() {
|
||||
final String filterName = "target_filter_03";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(),
|
||||
distributionSet.getId());
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), distributionSet.getId());
|
||||
|
||||
// Check if target filter query is there
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
@@ -218,8 +217,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
assignDistributionSet(distributionSet.getId(), target.getControllerId());
|
||||
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
|
||||
.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"))
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"))
|
||||
.getId(), distributionSet.getId());
|
||||
|
||||
// Check if target filter query is there with the distribution set
|
||||
@@ -247,30 +245,27 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
assertEquals(0L, targetFilterQueryManagement.count());
|
||||
|
||||
targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name("b").query("name==*"));
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("b").query("name==*"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final DistributionSet distributionSet2 = testdataFactory.createDistributionSet("2");
|
||||
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("c").query("name==x")).getId(),
|
||||
distributionSet.getId());
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name("c").query("name==x")).getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
final TargetFilterQuery tfq2 = targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==z*")).getId(),
|
||||
targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==z*")).getId(),
|
||||
distributionSet2.getId());
|
||||
|
||||
assertEquals(4L, targetFilterQueryManagement.count());
|
||||
|
||||
// check if find works
|
||||
Page<TargetFilterQuery> tfqList = targetFilterQueryManagement
|
||||
.findByAutoAssignDSAndRsql(new PageRequest(0, 500), distributionSet.getId(), null);
|
||||
Page<TargetFilterQuery> tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500),
|
||||
distributionSet.getId(), null);
|
||||
assertThat(1L).as("Target filter query").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq.getId(), tfqList.iterator().next().getId());
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.junit.Assert;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.bus.event.RemoteApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.event.ApplicationEventMulticaster;
|
||||
@@ -47,6 +48,25 @@ public class EventVerifier extends AbstractTestExecutionListener {
|
||||
|
||||
private EventCaptor eventCaptor;
|
||||
|
||||
/**
|
||||
* Publishes a reset counter marker event on the context to reset the
|
||||
* current counted events. This allows test to prepare a setup such in
|
||||
* {@code @Before} annotations which are actually counted to the executed
|
||||
* test-method and maybe fire events which are not covered / recognized by
|
||||
* the test-method itself and reset the counter again.
|
||||
*
|
||||
* Note that this approach is only working when using a single-thread
|
||||
* executor in the ApplicationEventMultiCaster, so the order of the events
|
||||
* keep the same.
|
||||
*
|
||||
* @param publisher
|
||||
* the {@link ApplicationEventPublisher} to publish the marker
|
||||
* event to
|
||||
*/
|
||||
public static void publishResetMarkerEvent(final ApplicationEventPublisher publisher) {
|
||||
publisher.publishEvent(new ResetCounterMarkerEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTestMethod(final TestContext testContext) throws Exception {
|
||||
final Optional<Expect[]> expectedEvents = getExpectationsFrom(testContext.getTestMethod());
|
||||
@@ -123,6 +143,12 @@ public class EventVerifier extends AbstractTestExecutionListener {
|
||||
public void onApplicationEvent(final RemoteApplicationEvent event) {
|
||||
LOGGER.debug("Received event {}", event.getClass().getSimpleName());
|
||||
|
||||
if (ResetCounterMarkerEvent.class.isAssignableFrom(event.getClass())) {
|
||||
LOGGER.debug("Retrieving reset counter marker event - resetting counters");
|
||||
capturedEvents.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event instanceof RemoteTenantAwareEvent) {
|
||||
assertThat(((RemoteTenantAwareEvent) event).getTenant()).isNotEmpty();
|
||||
}
|
||||
@@ -150,4 +176,12 @@ public class EventVerifier extends AbstractTestExecutionListener {
|
||||
|
||||
}
|
||||
|
||||
private static final class ResetCounterMarkerEvent extends RemoteApplicationEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ResetCounterMarkerEvent() {
|
||||
super(new Object(), "resetcounter");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.bus.ServiceMatcher;
|
||||
import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.auditing.AuditingHandler;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -196,6 +197,9 @@ public abstract class AbstractIntegrationTest {
|
||||
@Autowired
|
||||
protected ServiceMatcher serviceMatcher;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@Rule
|
||||
public final WithSpringAuthorityRule securityRule = new WithSpringAuthorityRule();
|
||||
|
||||
@@ -263,6 +267,7 @@ public abstract class AbstractIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
|
||||
final String description = "Updated description.";
|
||||
|
||||
osType = securityRule
|
||||
@@ -281,6 +286,15 @@ public abstract class AbstractIntegrationTest {
|
||||
.update(entityFactory.softwareModuleType().update(runtimeType.getId()).description(description)));
|
||||
|
||||
standardDsType = securityRule.runAsPrivileged(() -> testdataFactory.findOrCreateDefaultTestDsType());
|
||||
|
||||
// publish the reset counter market event to reset the counters after
|
||||
// setup. The setup is transparent by the test and its @ExpectedEvent
|
||||
// counting so we reset the counter here after the setup. Note that this
|
||||
// approach is only working when using a single-thread executor in the
|
||||
// ApplicationEventMultiCaster which the TestConfiguration is doing so
|
||||
// the order of the events keep the same.
|
||||
EventVerifier.publishResetMarkerEvent(eventPublisher);
|
||||
|
||||
}
|
||||
|
||||
private static String artifactDirectory = "./artifactrepo/" + RandomStringUtils.randomAlphanumeric(20);
|
||||
|
||||
Reference in New Issue
Block a user