use of io.gravitee.rest.api.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 {
if (plan.equals(UNKNOWN_SERVICE) || plan.equals(UNKNOWN_SERVICE_MAPPED)) {
metadata.put(METADATA_NAME, METADATA_UNKNOWN_PLAN_NAME);
metadata.put(METADATA_UNKNOWN, Boolean.TRUE.toString());
} else {
PlanEntity planEntity = planService.findById(plan);
metadata.put(METADATA_NAME, planEntity.getName());
}
} catch (PlanNotFoundException anfe) {
metadata.put(METADATA_DELETED, Boolean.TRUE.toString());
metadata.put(METADATA_NAME, METADATA_DELETED_PLAN_NAME);
}
return metadata;
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class APIV1toAPIV2ConverterTest method apiWithOnlyPlans.
@Test
public void apiWithOnlyPlans() throws Exception {
ApiEntity toMigrate = load("/io/gravitee/rest/api/service/migration/api-withOnlyPlans.json", ApiEntity.class);
ApiEntity expected = load("/io/gravitee/rest/api/service/migration/api-withOnlyPlans-migrated.json", ApiEntity.class);
Set<PlanEntity> planEntities = loadSet("/io/gravitee/rest/api/service/migration/plans.json", PlanEntity.class);
ApiEntity actual = cut.migrateToV2(toMigrate, policies, planEntities);
assertEqualsApiEntity(expected, actual);
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PlanService_CreateOrUpdateTest method shouldUpdateAndHaveNoId.
@Test
public void shouldUpdateAndHaveNoId() throws TechnicalException {
final PlanEntity expected = new PlanEntity();
expected.setId("updated");
when(planEntity.getId()).thenReturn(null);
doReturn(singletonList(expected)).when(planService).search(any());
doReturn(expected).when(planService).update(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)).update(any());
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PlanService_CreateOrUpdateTest method shouldThrowExceptionWhenTooManyResults.
@Test(expected = TechnicalManagementException.class)
public void shouldThrowExceptionWhenTooManyResults() throws TechnicalException {
final PlanEntity expected = new PlanEntity();
expected.setId("updated");
final ArrayList<PlanEntity> searchResult = new ArrayList<>();
searchResult.add(new PlanEntity());
searchResult.add(new PlanEntity());
when(planEntity.getId()).thenReturn(null);
doReturn(searchResult).when(planService).search(any());
final PlanEntity actual = planService.createOrUpdatePlan(planEntity, ENVIRONMENT_ID);
assertThat(actual.getId()).isEqualTo(expected.getId());
verify(planService, times(1)).search(any());
}
use of io.gravitee.rest.api.model.PlanEntity in project gravitee-management-rest-api by gravitee-io.
the class PlanService_CreateOrUpdateTest method shouldCreateAndHaveId.
@Test
public void shouldCreateAndHaveId() throws TechnicalException {
final PlanEntity expected = new PlanEntity();
expected.setId("created");
when(planEntity.getId()).thenReturn(PLAN_ID);
doThrow(PlanNotFoundException.class).when(planService).findById(PLAN_ID);
doReturn(expected).when(planService).create(any());
final PlanEntity actual = planService.createOrUpdatePlan(planEntity, ENVIRONMENT_ID);
assertThat(actual.getId()).isEqualTo(expected.getId());
verify(planService, times(1)).findById(PLAN_ID);
verify(planService, times(1)).create(any());
}
Aggregations