use of com.redhat.cloud.notifications.models.EventType in project notifications-backend by RedHatInsights.
the class ValidationResourceTest method shouldReturnStatusOkWhenTripleExists.
@Test
void shouldReturnStatusOkWhenTripleExists() {
EventType eventType = new EventType();
when(applicationRepository.getEventType(eq("my-bundle"), eq("Policies"), eq("Any"))).thenReturn(eventType);
String identityHeaderValue = TestHelpers.encodeRHIdentityInfo("empty", "empty", "user");
Header identityHeader = TestHelpers.createRHIdentityHeader(identityHeaderValue);
MockServerConfig.addMockRbacAccess(identityHeaderValue, FULL_ACCESS);
given().header(identityHeader).when().param("bundle", "my-bundle").param("application", "Policies").param("eventType", "Any").get(API_INTERNAL + "/validation/baet").then().statusCode(200);
}
use of com.redhat.cloud.notifications.models.EventType 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());
}
use of com.redhat.cloud.notifications.models.EventType in project notifications-backend by RedHatInsights.
the class BehaviorGroupRepositoryTest method createEventType.
@Transactional
EventType createEventType(Application app) {
EventType eventType = new EventType();
eventType.setApplication(app);
eventType.setApplicationId(app.getId());
eventType.setName("name");
eventType.setDisplayName("displayName");
entityManager.persist(eventType);
return eventType;
}
use of com.redhat.cloud.notifications.models.EventType in project notifications-backend by RedHatInsights.
the class BehaviorGroupRepositoryTest method testAddEventTypeBehaviorWithBundleIntegrityCheckFailure.
@Test
void testAddEventTypeBehaviorWithBundleIntegrityCheckFailure() {
/*
* Bundle 1 objects hierarchy.
*/
Bundle bundle1 = resourceHelpers.createBundle("bundle-1", "Bundle 1");
Application app = resourceHelpers.createApplication(bundle1.getId());
// 'eventType' is a child of 'bundle1'.
EventType eventType = createEventType(app);
// 'behaviorGroup1' is a child of 'bundle1'.
BehaviorGroup behaviorGroup1 = resourceHelpers.createBehaviorGroup(DEFAULT_ACCOUNT_ID, "Behavior group 1", bundle1.getId());
/*
* Bundle 2 objects hierarchy.
*/
Bundle bundle2 = resourceHelpers.createBundle("bundle-2", "Bundle 2");
// 'behaviorGroup2' is a child of 'bundle2'.
BehaviorGroup behaviorGroup2 = resourceHelpers.createBehaviorGroup(DEFAULT_ACCOUNT_ID, "Behavior group 2", bundle2.getId());
// 'behaviorGroup2' should not be added to 'eventType' behaviors because it comes from a different bundle.
BadRequestException e = assertThrows(BadRequestException.class, () -> {
behaviorGroupRepository.updateEventTypeBehaviors(DEFAULT_ACCOUNT_ID, eventType.getId(), Set.of(behaviorGroup1.getId(), behaviorGroup2.getId()));
});
assertTrue(e.getMessage().startsWith("Some behavior groups can't be linked"));
}
use of com.redhat.cloud.notifications.models.EventType in project notifications-backend by RedHatInsights.
the class LifecycleITest method createEventType.
private String createEventType(Header header, String appId) {
EventType eventType = new EventType();
eventType.setApplicationId(UUID.fromString(appId));
eventType.setName(EVENT_TYPE_NAME);
eventType.setDisplayName("Policies will take care of the rules");
eventType.setDescription("Policies is super cool, you should use it");
String responseBody = given().when().basePath(API_INTERNAL).header(header).contentType(JSON).body(Json.encode(eventType)).post("/eventTypes").then().statusCode(200).contentType(JSON).extract().body().asString();
JsonObject jsonEventType = new JsonObject(responseBody);
jsonEventType.mapTo(EventType.class);
assertNotNull(jsonEventType.getString("id"));
assertEquals(eventType.getName(), jsonEventType.getString("name"));
assertEquals(eventType.getDisplayName(), jsonEventType.getString("display_name"));
assertEquals(eventType.getDescription(), jsonEventType.getString("description"));
return jsonEventType.getString("id");
}
Aggregations