Search in sources :

Example 46 with ApiEntity

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);
}
Also used : ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Document(org.apache.lucene.document.Document) Test(org.junit.Test)

Example 47 with ApiEntity

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;
}
Also used : Proxy(io.gravitee.definition.model.Proxy) HashMap(java.util.HashMap) PrimaryOwnerEntity(io.gravitee.rest.api.model.PrimaryOwnerEntity) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) VirtualHost(io.gravitee.definition.model.VirtualHost) UserEntity(io.gravitee.rest.api.model.UserEntity) Date(java.util.Date) NotNull(org.jetbrains.annotations.NotNull)

Example 48 with ApiEntity

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);
}
Also used : ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 49 with ApiEntity

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);
}
Also used : PlanEntity(io.gravitee.rest.api.model.PlanEntity) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Test(org.junit.Test)

Example 50 with ApiEntity

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;
    }
}
Also used : ApiEntity(io.gravitee.rest.api.model.api.ApiEntity)

Aggregations

ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)273 Test (org.junit.Test)180 Response (javax.ws.rs.core.Response)65 Before (org.junit.Before)46 ApiQuery (io.gravitee.rest.api.model.api.ApiQuery)35 Error (io.gravitee.rest.api.portal.rest.model.Error)32 java.util (java.util)30 Collectors (java.util.stream.Collectors)27 Mockito.doReturn (org.mockito.Mockito.doReturn)27 Mockito (org.mockito.Mockito)25 ArgumentMatchers (org.mockito.ArgumentMatchers)24 UpdateApiEntity (io.gravitee.rest.api.model.api.UpdateApiEntity)23 Assert (org.junit.Assert)22 Collections.singletonList (java.util.Collections.singletonList)21 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)20 IOException (java.io.IOException)20 HttpStatusCode (io.gravitee.common.http.HttpStatusCode)19 Entity (javax.ws.rs.client.Entity)19 HashSet (java.util.HashSet)18 Api (io.gravitee.repository.management.model.Api)17