use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class ApplicationSubscriptionsResource method convert.
private Subscription convert(SubscriptionEntity subscriptionEntity) {
Subscription subscription = new Subscription();
subscription.setId(subscriptionEntity.getId());
subscription.setCreatedAt(subscriptionEntity.getCreatedAt());
subscription.setUpdatedAt(subscriptionEntity.getUpdatedAt());
subscription.setStartingAt(subscriptionEntity.getStartingAt());
subscription.setEndingAt(subscriptionEntity.getEndingAt());
subscription.setProcessedAt(subscriptionEntity.getProcessedAt());
subscription.setProcessedBy(subscriptionEntity.getProcessedBy());
subscription.setReason(subscriptionEntity.getReason());
subscription.setRequest(subscriptionEntity.getRequest());
subscription.setStatus(subscriptionEntity.getStatus());
subscription.setSubscribedBy(new Subscription.User(subscriptionEntity.getSubscribedBy(), userService.findById(subscriptionEntity.getSubscribedBy(), true).getDisplayName()));
PlanEntity plan = planService.findById(subscriptionEntity.getPlan());
subscription.setPlan(new Subscription.Plan(plan.getId(), plan.getName()));
subscription.getPlan().setSecurity(plan.getSecurity());
ApiEntity api = apiService.findById(subscriptionEntity.getApi());
subscription.setApi(new Subscription.Api(api.getId(), api.getName(), api.getVersion(), new Subscription.User(api.getPrimaryOwner().getId(), api.getPrimaryOwner().getDisplayName())));
subscription.setClosedAt(subscriptionEntity.getClosedAt());
subscription.setPausedAt(subscriptionEntity.getPausedAt());
return subscription;
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PageService_DeleteTest method shouldNotDeletePage_UsedBy_PUBLISHED_Plan.
@Test(expected = PageUsedAsGeneralConditionsException.class)
public void shouldNotDeletePage_UsedBy_PUBLISHED_Plan() throws TechnicalException {
Page page = mock(Page.class);
when(page.getId()).thenReturn(PAGE_ID);
when(page.getReferenceType()).thenReturn(PageReferenceType.API);
when(page.getReferenceId()).thenReturn(API_ID);
PlanEntity plan = mock(PlanEntity.class);
when(plan.getGeneralConditions()).thenReturn(PAGE_ID);
when(plan.getStatus()).thenReturn(PlanStatus.PUBLISHED);
when(pageRepository.findById(PAGE_ID)).thenReturn(Optional.of(page));
when(planService.findByApi(API_ID)).thenReturn(Sets.newHashSet(plan));
pageService.delete(PAGE_ID);
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PageService_DeleteTest method shouldDeletePage_UsedBy_CLOSED_Plan.
@Test
public void shouldDeletePage_UsedBy_CLOSED_Plan() throws TechnicalException {
Page page = mock(Page.class);
when(page.getId()).thenReturn(PAGE_ID);
when(page.getReferenceType()).thenReturn(PageReferenceType.API);
when(page.getReferenceId()).thenReturn(API_ID);
when(page.getVisibility()).thenReturn("PUBLIC");
PlanEntity plan = mock(PlanEntity.class);
when(plan.getGeneralConditions()).thenReturn(PAGE_ID);
when(plan.getStatus()).thenReturn(PlanStatus.CLOSED);
when(pageRepository.findById(PAGE_ID)).thenReturn(Optional.of(page));
when(planService.findByApi(API_ID)).thenReturn(Sets.newHashSet(plan));
pageService.delete(PAGE_ID);
verify(pageRepository).delete(PAGE_ID);
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PageService_DeleteTest method shouldNotDeletePage_UsedBy_STAGING_Plan.
@Test(expected = PageUsedAsGeneralConditionsException.class)
public void shouldNotDeletePage_UsedBy_STAGING_Plan() throws TechnicalException {
Page page = mock(Page.class);
when(page.getId()).thenReturn(PAGE_ID);
when(page.getReferenceType()).thenReturn(PageReferenceType.API);
when(page.getReferenceId()).thenReturn(API_ID);
PlanEntity plan = mock(PlanEntity.class);
when(plan.getGeneralConditions()).thenReturn(PAGE_ID);
when(plan.getStatus()).thenReturn(PlanStatus.STAGING);
when(pageRepository.findById(PAGE_ID)).thenReturn(Optional.of(page));
when(planService.findByApi(API_ID)).thenReturn(Sets.newHashSet(plan));
pageService.delete(PAGE_ID);
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PageService_DeleteTest method shouldNotDeleteTranslationPage_UsedBy_PUBLISHED_Plan.
@Test(expected = PageUsedAsGeneralConditionsException.class)
public void shouldNotDeleteTranslationPage_UsedBy_PUBLISHED_Plan() throws TechnicalException {
Page translationPage = mock(Page.class);
when(translationPage.getType()).thenReturn(PageType.TRANSLATION.name());
when(translationPage.getParentId()).thenReturn(PAGE_ID);
when(translationPage.getReferenceType()).thenReturn(PageReferenceType.API);
when(translationPage.getReferenceId()).thenReturn(API_ID);
PlanEntity plan = mock(PlanEntity.class);
when(plan.getGeneralConditions()).thenReturn(PAGE_ID);
when(plan.getStatus()).thenReturn(PlanStatus.PUBLISHED);
when(pageRepository.findById(TRANSLATE_PAGE_ID)).thenReturn(Optional.of(translationPage));
when(planService.findByApi(API_ID)).thenReturn(Sets.newHashSet(plan));
pageService.delete(TRANSLATE_PAGE_ID);
}
Aggregations