Search in sources :

Example 1 with TestTransaction

use of io.quarkus.test.TestTransaction in project notifications-backend by RedHatInsights.

the class DailyEmailAggregationJobTest method shouldProcessOneSubscriptionOnly.

@Test
@TestTransaction
void shouldProcessOneSubscriptionOnly() {
    helpers.addEmailAggregation("tenant", "someOrgId", "rhel", "policies", "somePolicyId", "someHostId");
    helpers.addEmailAggregation("tenant", "someOrgId", "rhel", "policies", "somePolicyId", "someHostId");
    final List<AggregationCommand> emailAggregations = testee.processAggregateEmails(LocalDateTime.now(UTC), new CollectorRegistry());
    assertEquals(1, emailAggregations.size());
    final AggregationCommand aggregationCommand = emailAggregations.get(0);
    assertEquals("tenant", aggregationCommand.getAggregationKey().getAccountId());
    assertEquals("someOrgId", aggregationCommand.getAggregationKey().getOrgId());
    assertEquals("rhel", aggregationCommand.getAggregationKey().getBundle());
    assertEquals("policies", aggregationCommand.getAggregationKey().getApplication());
    assertEquals(DAILY, aggregationCommand.getSubscriptionType());
}
Also used : AggregationCommand(com.redhat.cloud.notifications.models.AggregationCommand) CollectorRegistry(io.prometheus.client.CollectorRegistry) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) TestTransaction(io.quarkus.test.TestTransaction)

Example 2 with TestTransaction

use of io.quarkus.test.TestTransaction in project notifications-backend by RedHatInsights.

the class DailyEmailAggregationJobTest method shouldNotIncreaseAggregationsWhenHostIdIsDifferent.

@Test
@TestTransaction
void shouldNotIncreaseAggregationsWhenHostIdIsDifferent() {
    helpers.addEmailAggregation("someTenant", "someOrgId", "someRhel", "somePolicies", "somePolicyId", "hostId1");
    helpers.addEmailAggregation("someTenant", "someOrgId", "someRhel", "somePolicies", "somePolicyId", "hostId2");
    final List<AggregationCommand> emailAggregations = testee.processAggregateEmails(LocalDateTime.now(UTC), new CollectorRegistry());
    assertEquals(1, emailAggregations.size());
}
Also used : AggregationCommand(com.redhat.cloud.notifications.models.AggregationCommand) CollectorRegistry(io.prometheus.client.CollectorRegistry) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) TestTransaction(io.quarkus.test.TestTransaction)

Example 3 with TestTransaction

use of io.quarkus.test.TestTransaction in project notifications-backend by RedHatInsights.

the class DailyEmailAggregationJobTest method shouldProcessFourSubscriptions.

@Test
@TestTransaction
void shouldProcessFourSubscriptions() {
    helpers.addEmailAggregation("tenant", "someOrgId", "rhel", "policies", "somePolicyId", "someHostId");
    helpers.addEmailAggregation("tenant", "someOrgId", "rhel", "unknown-application", "somePolicyId", "someHostId");
    helpers.addEmailAggregation("tenant", "someOrgId", "unknown-bundle", "policies", "somePolicyId", "someHostId");
    helpers.addEmailAggregation("tenant", "someOrgId", "unknown-bundle", "unknown-application", "somePolicyId", "someHostId");
    final List<AggregationCommand> emailAggregations = testee.processAggregateEmails(LocalDateTime.now(UTC), new CollectorRegistry());
    assertEquals(4, emailAggregations.size());
}
Also used : AggregationCommand(com.redhat.cloud.notifications.models.AggregationCommand) CollectorRegistry(io.prometheus.client.CollectorRegistry) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) TestTransaction(io.quarkus.test.TestTransaction)

Example 4 with TestTransaction

use of io.quarkus.test.TestTransaction in project notifications-backend by RedHatInsights.

the class DailyEmailAggregationJobTest method shouldNotIncreaseAggregationsWhenPolicyIdIsDifferent.

@Test
@TestTransaction
void shouldNotIncreaseAggregationsWhenPolicyIdIsDifferent() {
    helpers.addEmailAggregation("someTenant", "someOrgId", "someRhel", "somePolicies", "policyId1", "someHostId");
    helpers.addEmailAggregation("someTenant", "someOrgId", "someRhel", "somePolicies", "policyId2", "someHostId");
    final List<AggregationCommand> emailAggregations = testee.processAggregateEmails(LocalDateTime.now(UTC), new CollectorRegistry());
    assertEquals(1, emailAggregations.size());
}
Also used : AggregationCommand(com.redhat.cloud.notifications.models.AggregationCommand) CollectorRegistry(io.prometheus.client.CollectorRegistry) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) TestTransaction(io.quarkus.test.TestTransaction)

Example 5 with TestTransaction

use of io.quarkus.test.TestTransaction in project notifications-backend by RedHatInsights.

the class DailyEmailAggregationJobTest method shouldProcessZeroAggregations.

@Test
@TestTransaction
void shouldProcessZeroAggregations() {
    final List<AggregationCommand> emailAggregations = testee.processAggregateEmails(LocalDateTime.now(UTC), new CollectorRegistry());
    assertEquals(0, emailAggregations.size());
}
Also used : AggregationCommand(com.redhat.cloud.notifications.models.AggregationCommand) CollectorRegistry(io.prometheus.client.CollectorRegistry) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) TestTransaction(io.quarkus.test.TestTransaction)

Aggregations

CollectorRegistry (io.prometheus.client.CollectorRegistry)6 TestTransaction (io.quarkus.test.TestTransaction)6 QuarkusTest (io.quarkus.test.junit.QuarkusTest)6 Test (org.junit.jupiter.api.Test)6 AggregationCommand (com.redhat.cloud.notifications.models.AggregationCommand)5 Gauge (io.prometheus.client.Gauge)1