Search in sources :

Example 1 with SingleRolloutPlanGroup

use of org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnGroupPropertySeparator.

@Test
public void testEndsOnGroupPropertySeparator() throws Exception {
    parse(":do{ rollout groupA( prop = v,");
    assertFalse(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertFalse(group.endsOnPropertyListStart());
    assertFalse(group.endsOnPropertyListEnd());
    assertTrue(group.hasProperties());
    assertFalse(group.endsOnPropertyValueSeparator());
    assertNull(group.getLastPropertyName());
    assertNull(group.getLastPropertyValue());
    assertTrue(group.endsOnPropertySeparator());
    assertEquals(29, group.getLastSeparatorIndex());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 2 with SingleRolloutPlanGroup

use of org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnGroupPropertiesEnd.

@Test
public void testEndsOnGroupPropertiesEnd() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout groupA()");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertFalse(group.endsOnPropertyListStart());
    assertTrue(group.endsOnPropertyListEnd());
    assertFalse(group.hasProperties());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 3 with SingleRolloutPlanGroup

use of org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testSpaceBeforeGroupPropertiesStart.

public void testSpaceBeforeGroupPropertiesStart() throws Exception {
    parse(":do{ rollout groupA (");
    assertFalse(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertTrue(group.endsOnPropertyListStart());
    assertFalse(group.endsOnPropertyListEnd());
    assertFalse(group.hasProperties());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader)

Example 4 with SingleRolloutPlanGroup

use of org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnGroupPropertiesStart.

@Test
public void testEndsOnGroupPropertiesStart() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout groupA(");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertTrue(group.endsOnPropertyListStart());
    assertFalse(group.endsOnPropertyListEnd());
    assertFalse(group.hasProperties());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 5 with SingleRolloutPlanGroup

use of org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup in project wildfly-core by wildfly.

the class RolloutPlanHeaderCallbackHandler method enteredState.

@Override
public void enteredState(ParsingContext ctx) throws CommandFormatException {
    final String id = ctx.getState().getId();
    if (HeaderValueState.ID.equals(id)) {
        ctx.enterState(RolloutPlanState.INSTANCE);
    } else if (ServerGroupState.ID.equals(id)) {
        group = new SingleRolloutPlanGroup();
    } else if (ConcurrentSignState.ID.equals(id)) {
        concurrent = true;
        header.groupConcurrentSeparator(ctx.getLocation());
    } else if ("NAME_VALUE_SEPARATOR".equals(id)) {
        name = buffer.length() == 0 ? null : buffer.toString().trim();
        if (name == null || name.isEmpty()) {
            throw new CommandFormatException("Property is missing name at index " + ctx.getLocation());
        }
        if (group != null) {
            group.addProperty(name, lastChunkIndex);
            group.propertyValueSeparator(ctx.getLocation());
        } else {
            header.planIdValueSeparator(ctx.getLocation());
        }
    } else if (ServerGroupSeparatorState.ID.equals(id)) {
        header.groupSequenceSeparator(ctx.getLocation());
    } else if (PropertyListState.ID.equals(id)) {
        if (group != null) {
            group.propertyListStart(ctx.getLocation());
        } else {
            header.propertyListStart(ctx.getLocation());
        }
    }
    buffer.setLength(0);
    lastChunkIndex = ctx.getLocation();
}
Also used : SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) CommandFormatException(org.jboss.as.cli.CommandFormatException)

Aggregations

SingleRolloutPlanGroup (org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup)9 ParsedRolloutPlanHeader (org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader)8 ParsedOperationRequestHeader (org.jboss.as.cli.operation.ParsedOperationRequestHeader)7 Test (org.junit.Test)7 CommandFormatException (org.jboss.as.cli.CommandFormatException)1 ModelNode (org.jboss.dmr.ModelNode)1