Search in sources :

Example 1 with PlanEntity

use of io.gravitee.management.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.

the class SubscriptionsResource 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.setStatus(subscriptionEntity.getStatus());
    ApplicationEntity application = applicationService.findById(subscriptionEntity.getApplication());
    subscription.setApplication(new Subscription.Application(application.getId(), application.getName(), application.getType(), new Subscription.User(application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName())));
    PlanEntity plan = planService.findById(subscriptionEntity.getPlan());
    subscription.setPlan(new Subscription.Plan(plan.getId(), plan.getName()));
    subscription.setClosedAt(subscriptionEntity.getClosedAt());
    return subscription;
}
Also used : ApplicationEntity(io.gravitee.management.model.ApplicationEntity) PlanEntity(io.gravitee.management.model.PlanEntity) Subscription(io.gravitee.management.rest.model.Subscription)

Example 2 with PlanEntity

use of io.gravitee.management.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.

the class AnalyticsServiceImpl method getPlanMetadata.

private Map<String, String> getPlanMetadata(String plan) {
    Map<String, String> metadata = new HashMap<>();
    try {
        PlanEntity planEntity = planService.findById(plan);
        metadata.put("name", planEntity.getName());
    } catch (PlanNotFoundException anfe) {
        metadata.put("deleted", "true");
    }
    return metadata;
}
Also used : PlanEntity(io.gravitee.management.model.PlanEntity)

Example 3 with PlanEntity

use of io.gravitee.management.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.

the class PlanService_FindByIdTest method shouldFindById.

@Test
public void shouldFindById() throws TechnicalException {
    when(plan.getType()).thenReturn(Plan.PlanType.API);
    when(plan.getValidation()).thenReturn(Plan.PlanValidationType.AUTO);
    when(planRepository.findById(PLAN_ID)).thenReturn(Optional.of(plan));
    final PlanEntity planEntity = planService.findById(PLAN_ID);
    assertNotNull(planEntity);
}
Also used : PlanEntity(io.gravitee.management.model.PlanEntity) Test(org.junit.Test)

Aggregations

PlanEntity (io.gravitee.management.model.PlanEntity)3 ApplicationEntity (io.gravitee.management.model.ApplicationEntity)1 Subscription (io.gravitee.management.rest.model.Subscription)1 Test (org.junit.Test)1