Java Code Examples for org.apache.nifi.web.api.dto.FunnelDTO#setId()

The following examples show how to use org.apache.nifi.web.api.dto.FunnelDTO#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ITFunnelAccessControl.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures the WRITE user can put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());

    final double y = 15.0;

    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(entity.getId());
    requestDto.setPosition(new PositionDTO(0.0, y));

    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);

    final FunnelEntity requestEntity = new FunnelEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);

    // perform the request
    final ClientResponse response = updateFunnel(helper.getWriteUser(), requestEntity);

    // ensure successful response
    assertEquals(200, response.getStatus());

    // get the response
    final FunnelEntity responseEntity = response.getEntity(FunnelEntity.class);

    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
 
Example 2
Source File: ITFunnelAccessControl.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures the NONE user cannot put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getNoneUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertFalse(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());

    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(entity.getId());
    requestDto.setPosition(new PositionDTO(0.0, 15.0));

    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);

    final FunnelEntity requestEntity = new FunnelEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);

    // perform the request
    final ClientResponse response = updateFunnel(helper.getNoneUser(), requestEntity);

    // ensure forbidden response
    assertEquals(403, response.getStatus());
}
 
Example 3
Source File: FlowFromDOMFactory.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public static FunnelDTO getFunnel(final Element element) {
    final FunnelDTO dto = new FunnelDTO();
    dto.setId(getString(element, "id"));
    dto.setPosition(getPosition(DomUtils.getChild(element, "position")));

    return dto;
}
 
Example 4
Source File: ITFunnelAccessControl.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures the WRITE user can put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());

    final double y = 15.0;

    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(entity.getId());
    requestDto.setPosition(new PositionDTO(0.0, y));

    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);

    final FunnelEntity requestEntity = new FunnelEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);

    // perform the request
    final Response response = updateFunnel(helper.getWriteUser(), requestEntity);

    // ensure successful response
    assertEquals(200, response.getStatus());

    // get the response
    final FunnelEntity responseEntity = response.readEntity(FunnelEntity.class);

    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
 
Example 5
Source File: ITFunnelAccessControl.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures the NONE user cannot put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutFunnel() throws Exception {
    final FunnelEntity entity = getRandomFunnel(helper.getNoneUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertFalse(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());

    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(entity.getId());
    requestDto.setPosition(new PositionDTO(0.0, 15.0));

    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);

    final FunnelEntity requestEntity = new FunnelEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);

    // perform the request
    final Response response = updateFunnel(helper.getNoneUser(), requestEntity);

    // ensure forbidden response
    assertEquals(403, response.getStatus());
}
 
Example 6
Source File: FlowFromDOMFactory.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static FunnelDTO getFunnel(final Element element) {
    final FunnelDTO dto = new FunnelDTO();
    dto.setId(getString(element, "id"));
    dto.setVersionedComponentId(getString(element, "versionedComponentId"));
    dto.setPosition(getPosition(DomUtils.getChild(element, "position")));

    return dto;
}