Search in sources :

Example 21 with FunnelEntity

use of org.apache.nifi.web.api.entity.FunnelEntity in project nifi by apache.

the class ITFunnelAccessControl method testReadWriteUserPutFunnel.

/**
 * Ensures the READ_WRITE user can put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testReadWriteUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getReadWriteUser());
    assertTrue(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNotNull(entity.getComponent());
    final double y = 15.0;
    // attempt to update the position
    final long version = entity.getRevision().getVersion();
    entity.getRevision().setClientId(AccessControlHelper.READ_WRITE_CLIENT_ID);
    entity.getComponent().setPosition(new PositionDTO(0.0, y));
    // perform the request
    final Response response = updateFunnel(helper.getReadWriteUser(), entity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final FunnelEntity responseEntity = response.readEntity(FunnelEntity.class);
    // verify
    assertEquals(READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
    assertEquals(y, responseEntity.getComponent().getPosition().getY().doubleValue(), 0);
}
Also used : FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) Response(javax.ws.rs.core.Response) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) Test(org.junit.Test)

Aggregations

FunnelEntity (org.apache.nifi.web.api.entity.FunnelEntity)21 Response (javax.ws.rs.core.Response)8 Test (org.junit.Test)8 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 Consumes (javax.ws.rs.Consumes)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 Authorizable (org.apache.nifi.authorization.resource.Authorizable)5 FunnelDTO (org.apache.nifi.web.api.dto.FunnelDTO)5 PositionDTO (org.apache.nifi.web.api.dto.PositionDTO)5 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)4 HashMap (java.util.HashMap)3 ConnectionEntity (org.apache.nifi.web.api.entity.ConnectionEntity)3 LabelEntity (org.apache.nifi.web.api.entity.LabelEntity)3 PortEntity (org.apache.nifi.web.api.entity.PortEntity)3 ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)3 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)3 Map (java.util.Map)2 GET (javax.ws.rs.GET)2