use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiDocumentTransformerTest method shouldTransform.
@Test
public void shouldTransform() {
ApiEntity toTransform = getApiEntity();
Document transformed = cut.transform(toTransform);
assertDocumentMatchesInputApiEntity(toTransform, transformed);
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiDocumentTransformerTest method getApiEntity.
@NotNull
private ApiEntity getApiEntity() {
ApiEntity toTransform = new ApiEntity();
toTransform.setId("apiId");
toTransform.setName("name");
toTransform.setDescription("description");
toTransform.setReferenceId("xxxxxx");
toTransform.setReferenceType("env1");
UserEntity userEntity = new UserEntity();
userEntity.setId("userId");
userEntity.setEmail("userMail");
userEntity.setFirstname("userFirstname");
userEntity.setLastname("userLastname");
PrimaryOwnerEntity primaryOwnerEntity = new PrimaryOwnerEntity(userEntity);
toTransform.setPrimaryOwner(primaryOwnerEntity);
Proxy proxy = new Proxy();
proxy.setVirtualHosts(Arrays.asList(new VirtualHost("host", "path"), new VirtualHost("host2", "path2")));
toTransform.setProxy(proxy);
toTransform.setLabels(Arrays.asList("label1", "label2", "label2"));
toTransform.setCategories(new HashSet<>(Arrays.asList("cat1", "cat2")));
toTransform.setTags(new HashSet<>(Arrays.asList("tag1", "tag2")));
Date date = new Date();
toTransform.setCreatedAt(date);
toTransform.setUpdatedAt(date);
HashMap<String, Object> metadatas = new HashMap<>();
metadatas.put("metadata1", "value1");
metadatas.put("metadata2", "value2");
metadatas.put("metadata3", "value3");
toTransform.setMetadata(metadatas);
return toTransform;
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class APIV1toAPIV2ConverterTest method apiWithMultiplePoliciesPerStep.
@Test
public void apiWithMultiplePoliciesPerStep() throws Exception {
ApiEntity toMigrate = load("/io/gravitee/rest/api/service/migration/api-withMultiplePolicies.json", ApiEntity.class);
ApiEntity expected = load("/io/gravitee/rest/api/service/migration/api-withMultiplePolicies-migrated.json", ApiEntity.class);
ApiEntity actual = cut.migrateToV2(toMigrate, policies, Collections.emptySet());
assertEqualsApiEntity(expected, actual);
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class APIV1toAPIV2ConverterTest method apiWithPathsAndPlans.
@Test
public void apiWithPathsAndPlans() throws Exception {
ApiEntity toMigrate = load("/io/gravitee/rest/api/service/migration/api-withPathsAndPlans.json", ApiEntity.class);
ApiEntity expected = load("/io/gravitee/rest/api/service/migration/api-withPathsAndPlans-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.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class DynamicPropertiesService method onEvent.
@Override
public void onEvent(Event<ApiEvent, ApiEntity> event) {
final ApiEntity api = event.content();
switch(event.type()) {
case DEPLOY:
startDynamicProperties(api);
break;
case UNDEPLOY:
stopDynamicProperties(api);
break;
case UPDATE:
stopDynamicProperties(api);
startDynamicProperties(api);
break;
}
}
Aggregations