Search in sources :

Example 11 with BehaviorGroup

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

the class BehaviorGroupRepositoryTest method testAddMultipleEmailSubscriptionBehaviorGroupActions.

@Test
void testAddMultipleEmailSubscriptionBehaviorGroupActions() {
    Bundle bundle = resourceHelpers.createBundle();
    BehaviorGroup behaviorGroup = resourceHelpers.createBehaviorGroup(DEFAULT_ACCOUNT_ID, "displayName", bundle.getId());
    Endpoint endpoint1 = resourceHelpers.createEndpoint(DEFAULT_ACCOUNT_ID, EMAIL_SUBSCRIPTION);
    Endpoint endpoint2 = resourceHelpers.createEndpoint(DEFAULT_ACCOUNT_ID, EMAIL_SUBSCRIPTION);
    updateAndCheckBehaviorGroupActions(DEFAULT_ACCOUNT_ID, bundle.getId(), behaviorGroup.getId(), OK, endpoint1.getId(), endpoint2.getId());
}
Also used : Endpoint(com.redhat.cloud.notifications.models.Endpoint) Bundle(com.redhat.cloud.notifications.models.Bundle) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Example 12 with BehaviorGroup

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

the class BehaviorGroupRepositoryTest method testFindBehaviorGroupsByEventTypeId.

@Test
void testFindBehaviorGroupsByEventTypeId() {
    Bundle bundle = resourceHelpers.createBundle();
    Application app = resourceHelpers.createApplication(bundle.getId());
    EventType eventType = createEventType(app);
    BehaviorGroup behaviorGroup = resourceHelpers.createBehaviorGroup(DEFAULT_ACCOUNT_ID, "displayName", bundle.getId());
    updateAndCheckEventTypeBehaviors(DEFAULT_ACCOUNT_ID, eventType.getId(), true, behaviorGroup.getId());
    List<BehaviorGroup> behaviorGroups = resourceHelpers.findBehaviorGroupsByEventTypeId(eventType.getId());
    assertEquals(1, behaviorGroups.size());
    assertEquals(behaviorGroup.getId(), behaviorGroups.get(0).getId());
}
Also used : EventType(com.redhat.cloud.notifications.models.EventType) Bundle(com.redhat.cloud.notifications.models.Bundle) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) Application(com.redhat.cloud.notifications.models.Application) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Example 13 with BehaviorGroup

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

the class NotificationResourceTest method testUpdateUnknownBehaviorGroupId.

@Test
void testUpdateUnknownBehaviorGroupId() {
    Header identityHeader = initRbacMock("tenant", "orgId", "user", FULL_ACCESS);
    BehaviorGroup behaviorGroup = new BehaviorGroup();
    behaviorGroup.setDisplayName("Behavior group");
    // Only used for @NotNull validation.
    behaviorGroup.setBundleId(UUID.randomUUID());
    given().header(identityHeader).contentType(JSON).pathParam("id", UUID.randomUUID()).body(Json.encode(behaviorGroup)).when().put("/notifications/behaviorGroups/{id}").then().statusCode(404);
}
Also used : Header(io.restassured.http.Header) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Example 14 with BehaviorGroup

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

the class BehaviorGroupRepositoryTest method testFindEventTypesByBehaviorGroupId.

@Test
void testFindEventTypesByBehaviorGroupId() {
    Bundle bundle = resourceHelpers.createBundle();
    Application app = resourceHelpers.createApplication(bundle.getId());
    EventType eventType = createEventType(app);
    BehaviorGroup behaviorGroup = resourceHelpers.createBehaviorGroup(DEFAULT_ACCOUNT_ID, "displayName", bundle.getId());
    updateAndCheckEventTypeBehaviors(DEFAULT_ACCOUNT_ID, eventType.getId(), true, behaviorGroup.getId());
    List<EventType> eventTypes = resourceHelpers.findEventTypesByBehaviorGroupId(behaviorGroup.getId());
    assertEquals(1, eventTypes.size());
    assertEquals(eventType.getId(), eventTypes.get(0).getId());
}
Also used : EventType(com.redhat.cloud.notifications.models.EventType) Bundle(com.redhat.cloud.notifications.models.Bundle) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) Application(com.redhat.cloud.notifications.models.Application) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Example 15 with BehaviorGroup

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

the class BehaviorGroupRepositoryTest method testUpdateBehaviorGroupActionsWithWrongAccountId.

@Test
void testUpdateBehaviorGroupActionsWithWrongAccountId() {
    Bundle bundle = resourceHelpers.createBundle();
    BehaviorGroup behaviorGroup = resourceHelpers.createBehaviorGroup(DEFAULT_ACCOUNT_ID, "displayName", bundle.getId());
    Endpoint endpoint = resourceHelpers.createEndpoint(DEFAULT_ACCOUNT_ID, WEBHOOK);
    updateAndCheckBehaviorGroupActions("unknownAccountId", bundle.getId(), behaviorGroup.getId(), NOT_FOUND, endpoint.getId());
}
Also used : Endpoint(com.redhat.cloud.notifications.models.Endpoint) Bundle(com.redhat.cloud.notifications.models.Bundle) BehaviorGroup(com.redhat.cloud.notifications.models.BehaviorGroup) QuarkusTest(io.quarkus.test.junit.QuarkusTest) DbIsolatedTest(com.redhat.cloud.notifications.db.DbIsolatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

BehaviorGroup (com.redhat.cloud.notifications.models.BehaviorGroup)28 Bundle (com.redhat.cloud.notifications.models.Bundle)12 QuarkusTest (io.quarkus.test.junit.QuarkusTest)12 Test (org.junit.jupiter.api.Test)12 DbIsolatedTest (com.redhat.cloud.notifications.db.DbIsolatedTest)11 EventType (com.redhat.cloud.notifications.models.EventType)8 Endpoint (com.redhat.cloud.notifications.models.Endpoint)6 Application (com.redhat.cloud.notifications.models.Application)5 NotFoundException (javax.ws.rs.NotFoundException)4 Transactional (javax.transaction.Transactional)3 ValidatableResponse (io.restassured.response.ValidatableResponse)2 BehaviorGroupAction (com.redhat.cloud.notifications.models.BehaviorGroupAction)1 BehaviorGroupActionId (com.redhat.cloud.notifications.models.BehaviorGroupActionId)1 EventTypeBehavior (com.redhat.cloud.notifications.models.EventTypeBehavior)1 EventTypeBehaviorId (com.redhat.cloud.notifications.models.EventTypeBehaviorId)1 Header (io.restassured.http.Header)1 JsonObject (io.vertx.core.json.JsonObject)1 BadRequestException (javax.ws.rs.BadRequestException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1