use of com.redhat.cloud.notifications.models.BehaviorGroup in project notifications-backend by RedHatInsights.
the class BehaviorGroupRepository method findEventTypesByBehaviorGroupId.
public List<EventType> findEventTypesByBehaviorGroupId(String accountId, UUID behaviorGroupId) {
BehaviorGroup behaviorGroup = entityManager.find(BehaviorGroup.class, behaviorGroupId);
if (behaviorGroup == null) {
throw new NotFoundException("Behavior group not found");
}
String query = "SELECT e FROM EventType e LEFT JOIN FETCH e.application JOIN e.behaviors b " + "WHERE (b.behaviorGroup.accountId = :accountId OR b.behaviorGroup.accountId IS NULL) AND b.behaviorGroup.id = :behaviorGroupId";
return entityManager.createQuery(query, EventType.class).setParameter("accountId", accountId).setParameter("behaviorGroupId", behaviorGroupId).getResultList();
}
use of com.redhat.cloud.notifications.models.BehaviorGroup in project notifications-backend by RedHatInsights.
the class BehaviorGroupRepository method findBehaviorGroupsByEndpointId.
public List<BehaviorGroup> findBehaviorGroupsByEndpointId(String accountId, UUID endpointId) {
Endpoint endpoint = entityManager.find(Endpoint.class, endpointId);
if (endpoint == null) {
throw new NotFoundException("Endpoint not found");
}
String query = "SELECT bg FROM BehaviorGroup bg LEFT JOIN FETCH bg.bundle JOIN bg.actions a WHERE bg.accountId = :accountId AND a.endpoint.id = :endpointId";
List<BehaviorGroup> behaviorGroups = entityManager.createQuery(query, BehaviorGroup.class).setParameter("accountId", accountId).setParameter("endpointId", endpointId).getResultList();
for (BehaviorGroup behaviorGroup : behaviorGroups) {
behaviorGroup.filterOutActions();
}
return behaviorGroups;
}
use of com.redhat.cloud.notifications.models.BehaviorGroup in project notifications-backend by RedHatInsights.
the class CrudTestHelpers method updateDefaultBehaviorGroup.
public static void updateDefaultBehaviorGroup(Header identity, String behaviorGroupId, String displayName, String bundleId, boolean expectedResult, int expectedStatus) {
BehaviorGroup behaviorGroup = buildDefaultBehaviorGroup(displayName, bundleId);
ValidatableResponse respoonse = given().header(identity).basePath(API_INTERNAL).contentType(JSON).body(Json.encode(behaviorGroup)).pathParam("id", behaviorGroupId).put("/behaviorGroups/default/{id}").then().statusCode(expectedStatus);
if (familyOf(expectedStatus) == SUCCESSFUL) {
Boolean result = respoonse.extract().as(Boolean.class);
assertEquals(expectedResult, result);
}
}
use of com.redhat.cloud.notifications.models.BehaviorGroup in project notifications-backend by RedHatInsights.
the class ResourceHelpers method createBehaviorGroup.
public BehaviorGroup createBehaviorGroup(String accountId, String displayName, UUID bundleId) {
BehaviorGroup behaviorGroup = new BehaviorGroup();
behaviorGroup.setDisplayName(displayName);
behaviorGroup.setBundleId(bundleId);
return behaviorGroupRepository.create(accountId, behaviorGroup);
}
use of com.redhat.cloud.notifications.models.BehaviorGroup in project notifications-backend by RedHatInsights.
the class ResourceHelpers method createDefaultBehaviorGroup.
public BehaviorGroup createDefaultBehaviorGroup(String displayName, UUID bundleId) {
BehaviorGroup behaviorGroup = new BehaviorGroup();
behaviorGroup.setDisplayName(displayName);
behaviorGroup.setBundleId(bundleId);
return behaviorGroupRepository.createDefault(behaviorGroup);
}
Aggregations