use of com.redhat.cloud.notifications.models.EventTypeBehavior in project notifications-backend by RedHatInsights.
the class BehaviorGroupRepositoryTest method updateAndCheckEventTypeBehaviors.
@Transactional
void updateAndCheckEventTypeBehaviors(String accountId, UUID eventTypeId, boolean expectedResult, UUID... behaviorGroupIds) {
boolean updated = behaviorGroupRepository.updateEventTypeBehaviors(accountId, eventTypeId, Set.of(behaviorGroupIds));
// Is the update result the one we expected?
assertEquals(expectedResult, updated);
if (expectedResult) {
// We need to clear the session L1 cache before checking the update result.
entityManager.clear();
// If we expected a success, the event type behaviors should match in any order the given behavior groups IDs.
List<EventTypeBehavior> behaviors = findEventTypeBehaviorByEventTypeId(eventTypeId);
assertEquals(behaviorGroupIds.length, behaviors.size());
for (UUID behaviorGroupId : behaviorGroupIds) {
assertEquals(1L, behaviors.stream().filter(behavior -> behavior.getBehaviorGroup().getId().equals(behaviorGroupId)).count());
}
}
}
use of com.redhat.cloud.notifications.models.EventTypeBehavior in project notifications-backend by RedHatInsights.
the class LifecycleITest method addEventTypeBehavior.
@Transactional
void addEventTypeBehavior(UUID eventTypeId, UUID behaviorGroupId) {
EventType eventType = entityManager.find(EventType.class, eventTypeId);
BehaviorGroup behaviorGroup = entityManager.find(BehaviorGroup.class, behaviorGroupId);
EventTypeBehavior behavior = new EventTypeBehavior();
behavior.setId(new EventTypeBehaviorId());
behavior.setEventType(eventType);
behavior.setBehaviorGroup(behaviorGroup);
entityManager.persist(behavior);
}
Aggregations