use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PlanService_CreateOrUpdateTest method shouldCreateAndHaveNoId.
@Test
public void shouldCreateAndHaveNoId() throws TechnicalException {
final PlanEntity expected = new PlanEntity();
expected.setId("created");
when(planEntity.getId()).thenReturn(null);
doReturn(emptyList()).when(planService).search(any());
doReturn(expected).when(planService).create(any());
final PlanEntity actual = planService.createOrUpdatePlan(planEntity, ENVIRONMENT_ID);
assertThat(actual.getId()).isEqualTo(expected.getId());
verify(planService, times(1)).search(any());
verify(planService, times(1)).create(any());
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class EmailNotifierServiceTest method shouldHaveATemplateForApplicationHooks.
@Test
public void shouldHaveATemplateForApplicationHooks() {
GenericNotificationConfig cfg = new GenericNotificationConfig();
cfg.setConfig("test@mail.com");
ApiEntity api = new ApiEntity();
api.setName("api-name");
PlanEntity plan = new PlanEntity();
plan.setName("plan-name");
Map<String, Object> params = new HashMap<>();
params.put((NotificationParamsBuilder.PARAM_API), api);
params.put((NotificationParamsBuilder.PARAM_PLAN), plan);
for (ApplicationHook hook : ApplicationHook.values()) {
reset(mockEmailService);
service.trigger(hook, cfg, params);
verify(mockEmailService, times(1)).sendAsyncEmailNotification(argThat(notification -> notification.getTo() != null && notification.getTo().length == 1 && notification.getTo()[0].equals("test@mail.com")), any());
verify(mockEmailService, never()).sendEmailNotification(any());
}
}
Aggregations