Search in sources :

Example 1 with EventTypeBehavior

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());
        }
    }
}
Also used : EventTypeBehavior(com.redhat.cloud.notifications.models.EventTypeBehavior) UUID(java.util.UUID) Transactional(javax.transaction.Transactional)

Example 2 with EventTypeBehavior

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);
}
Also used : EventType(com.redhat.cloud.notifications.models.EventType) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) EventTypeBehavior(com.redhat.cloud.notifications.models.EventTypeBehavior) EventTypeBehaviorId(com.redhat.cloud.notifications.models.EventTypeBehaviorId) Transactional(javax.transaction.Transactional)

Aggregations

EventTypeBehavior (com.redhat.cloud.notifications.models.EventTypeBehavior)2 Transactional (javax.transaction.Transactional)2 BehaviorGroup (com.redhat.cloud.notifications.models.BehaviorGroup)1 EventType (com.redhat.cloud.notifications.models.EventType)1 EventTypeBehaviorId (com.redhat.cloud.notifications.models.EventTypeBehaviorId)1 UUID (java.util.UUID)1