Search in sources :

Example 96 with ProcessGroupDTO

use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project nifi by apache.

the class ITProcessGroupAccessControl method testWriteUserPutProcessGroup.

/**
 * Ensures the WRITE user can put a process group.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutProcessGroup() throws Exception {
    final ProcessGroupEntity entity = getRandomProcessGroup(helper.getWriteUser());
    assertFalse(entity.getPermissions().getCanRead());
    assertTrue(entity.getPermissions().getCanWrite());
    assertNull(entity.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final ProcessGroupDTO requestDto = new ProcessGroupDTO();
    requestDto.setId(entity.getId());
    requestDto.setName(updatedName);
    final long version = entity.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);
    final ProcessGroupEntity requestEntity = new ProcessGroupEntity();
    requestEntity.setId(entity.getId());
    requestEntity.setRevision(requestRevision);
    requestEntity.setComponent(requestDto);
    // perform the request
    final Response response = updateProcessGroup(helper.getWriteUser(), requestEntity);
    // ensure successful response
    assertEquals(200, response.getStatus());
    // get the response
    final ProcessGroupEntity responseEntity = response.readEntity(ProcessGroupEntity.class);
    // verify
    assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId());
    assertEquals(version + 1, responseEntity.getRevision().getVersion().longValue());
}
Also used : Response(javax.ws.rs.core.Response) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) Test(org.junit.Test)

Aggregations

ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)96 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)35 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)32 ArrayList (java.util.ArrayList)29 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)29 PortDTO (org.apache.nifi.web.api.dto.PortDTO)27 HashSet (java.util.HashSet)25 HashMap (java.util.HashMap)20 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)18 FlowSnippetDTO (org.apache.nifi.web.api.dto.FlowSnippetDTO)18 NifiComponentNotFoundException (com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)16 List (java.util.List)16 Set (java.util.Set)16 Collectors (java.util.stream.Collectors)15 TemplateDTO (org.apache.nifi.web.api.dto.TemplateDTO)15 Map (java.util.Map)14 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)13 ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)13 Logger (org.slf4j.Logger)13 LoggerFactory (org.slf4j.LoggerFactory)13