Search in sources :

Example 6 with ApplicationMetadataEntity

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

the class ApplicationMetadataResourceTest method shouldCreateMetadata.

@Test
public void shouldCreateMetadata() {
    Mockito.reset(applicationMetadataService);
    NewApplicationMetadataEntity newMetadata = new NewApplicationMetadataEntity();
    newMetadata.setName("my-metadata-name");
    ApplicationMetadataEntity createdMetadata = new ApplicationMetadataEntity();
    createdMetadata.setKey("my-metadata-id");
    when(applicationMetadataService.create(any())).thenReturn(createdMetadata);
    final Response response = envTarget().path(APPLICATION).path("metadata").request().post(Entity.json(newMetadata));
    assertEquals(CREATED_201, response.getStatus());
    assertEquals(envTarget().path(APPLICATION).path("metadata").path("my-metadata-id").getUri().toString(), response.getHeaders().getFirst(HttpHeaders.LOCATION));
}
Also used : NewApplicationMetadataEntity(io.gravitee.rest.api.model.NewApplicationMetadataEntity) ApplicationMetadataEntity(io.gravitee.rest.api.model.ApplicationMetadataEntity) Response(javax.ws.rs.core.Response) NewApplicationMetadataEntity(io.gravitee.rest.api.model.NewApplicationMetadataEntity) Test(org.junit.Test)

Aggregations

ApplicationMetadataEntity (io.gravitee.rest.api.model.ApplicationMetadataEntity)6 NewApplicationMetadataEntity (io.gravitee.rest.api.model.NewApplicationMetadataEntity)6 UpdateApplicationMetadataEntity (io.gravitee.rest.api.model.UpdateApplicationMetadataEntity)5 Test (org.junit.Test)2 Permissions (io.gravitee.rest.api.management.rest.security.Permissions)1 ReferenceMetadata (io.gravitee.rest.api.portal.rest.model.ReferenceMetadata)1 Permissions (io.gravitee.rest.api.portal.rest.security.Permissions)1 ApplicationMetadataNotFoundException (io.gravitee.rest.api.service.exceptions.ApplicationMetadataNotFoundException)1 ApplicationNotFoundException (io.gravitee.rest.api.service.exceptions.ApplicationNotFoundException)1 Response (javax.ws.rs.core.Response)1 Before (org.junit.Before)1