Search in sources :

Example 1 with BehaviorGroupAction

use of com.redhat.cloud.notifications.models.BehaviorGroupAction in project notifications-backend by RedHatInsights.

the class LifecycleITest method addBehaviorGroupAction.

@Transactional
void addBehaviorGroupAction(UUID behaviorGroupId, UUID endpointId) {
    BehaviorGroup behaviorGroup = entityManager.find(BehaviorGroup.class, behaviorGroupId);
    Endpoint endpoint = entityManager.find(Endpoint.class, endpointId);
    BehaviorGroupAction action = new BehaviorGroupAction();
    action.setId(new BehaviorGroupActionId());
    action.setBehaviorGroup(behaviorGroup);
    action.setEndpoint(endpoint);
    entityManager.persist(action);
}
Also used : BehaviorGroupActionId(com.redhat.cloud.notifications.models.BehaviorGroupActionId) Endpoint(com.redhat.cloud.notifications.models.Endpoint) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) BehaviorGroupAction(com.redhat.cloud.notifications.models.BehaviorGroupAction) Transactional(javax.transaction.Transactional)

Example 2 with BehaviorGroupAction

use of com.redhat.cloud.notifications.models.BehaviorGroupAction in project notifications-backend by RedHatInsights.

the class BehaviorGroupRepositoryTest method updateAndCheckBehaviorGroupActions.

@Transactional
void updateAndCheckBehaviorGroupActions(String accountId, UUID bundleId, UUID behaviorGroupId, Status expectedResult, UUID... endpointIds) {
    Status status = behaviorGroupRepository.updateBehaviorGroupActions(accountId, behaviorGroupId, Arrays.asList(endpointIds));
    // Is the update result the one we expected?
    assertEquals(expectedResult, status);
    if (expectedResult == Status.OK) {
        // We need to clear the session L1 cache before checking the update result.
        entityManager.clear();
        // If we expected a success, the behavior group actions should match exactly the given endpoint IDs.
        List<BehaviorGroupAction> actions = findBehaviorGroupActions(accountId, bundleId, behaviorGroupId);
        assertEquals(endpointIds.length, actions.size());
        for (int i = 0; i < endpointIds.length; i++) {
            assertEquals(endpointIds[i], actions.get(i).getEndpoint().getId());
        }
    }
}
Also used : Status(javax.ws.rs.core.Response.Status) BehaviorGroupAction(com.redhat.cloud.notifications.models.BehaviorGroupAction) Endpoint(com.redhat.cloud.notifications.models.Endpoint) Transactional(javax.transaction.Transactional)

Aggregations

BehaviorGroupAction (com.redhat.cloud.notifications.models.BehaviorGroupAction)2 Endpoint (com.redhat.cloud.notifications.models.Endpoint)2 Transactional (javax.transaction.Transactional)2 BehaviorGroup (com.redhat.cloud.notifications.models.BehaviorGroup)1 BehaviorGroupActionId (com.redhat.cloud.notifications.models.BehaviorGroupActionId)1 Status (javax.ws.rs.core.Response.Status)1