@Test
  @Named("null if spec description is empty")
  @Order(1)
  public void _nullIfSpecDescriptionIsEmpty() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package test");
    _builder.newLine();
    _builder.append("describe \"\"{}");
    this._modelStore.parseSpec(_builder);
    String _qualifiedName = this.qualifiedName();
    Matcher<String> _nullValue = CoreMatchers.<String>nullValue();
    boolean _should_be = Should.<String>should_be(_qualifiedName, _nullValue);
    Assert.assertTrue(
        "\nExpected qualifiedName should be null but"
            + "\n     qualifiedName is "
            + new StringDescription().appendValue(_qualifiedName).toString()
            + "\n",
        _should_be);

    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("describe \"\"{}");
    this._modelStore.parseSpec(_builder_1);
    String _qualifiedName_1 = this.qualifiedName();
    Matcher<String> _nullValue_1 = CoreMatchers.<String>nullValue();
    boolean _should_be_1 = Should.<String>should_be(_qualifiedName_1, _nullValue_1);
    Assert.assertTrue(
        "\nExpected qualifiedName should be null but"
            + "\n     qualifiedName is "
            + new StringDescription().appendValue(_qualifiedName_1).toString()
            + "\n",
        _should_be_1);
  }
  @Test
  @Named("if waiting for response")
  @Order(1)
  public void _ifWaitingForResponse() throws Exception {
    boolean _isBusy = this.subject.isBusy();
    boolean _doubleArrow = Should.<Boolean>operator_doubleArrow(Boolean.valueOf(_isBusy), false);
    Assert.assertTrue(
        "\nExpected subject.busy => false but"
            + "\n     subject.busy is "
            + new org.hamcrest.StringDescription().appendValue(Boolean.valueOf(_isBusy)).toString()
            + "\n     subject is "
            + new org.hamcrest.StringDescription().appendValue(this.subject).toString()
            + "\n",
        _doubleArrow);

    final Answer<Callback<Response>> _function =
        new Answer<Callback<Response>>() {
          public Callback<Response> answer(final InvocationOnMock it) throws Throwable {
            Object[] _arguments = it.getArguments();
            Object _get = _arguments[1];
            return ConnectorBusySpec.this.callback = ((Callback) _get);
          }
        };
    Stubber _doAnswer = Mockito.doAnswer(_function);
    Connection _when = _doAnswer.<Connection>when(this.connection);
    Command _any = Matchers.<Command>any();
    Callback _any_1 = Matchers.<Callback>any();
    _when.<Response>sendRequest(_any, _any_1);
    this.subject.<Response>execute(this.anyCommand, this.callback);
    boolean _isBusy_1 = this.subject.isBusy();
    boolean _doubleArrow_1 = Should.<Boolean>operator_doubleArrow(Boolean.valueOf(_isBusy_1), true);
    Assert.assertTrue(
        "\nExpected subject.busy => true but"
            + "\n     subject.busy is "
            + new org.hamcrest.StringDescription()
                .appendValue(Boolean.valueOf(_isBusy_1))
                .toString()
            + "\n     subject is "
            + new org.hamcrest.StringDescription().appendValue(this.subject).toString()
            + "\n",
        _doubleArrow_1);

    Response _response = new Response(0, "");
    this.callback.handleResponse(_response);
    boolean _isBusy_2 = this.subject.isBusy();
    Assert.assertTrue(
        "\nExpected subject.busy => false but"
            + "\n     subject.busy is "
            + new org.hamcrest.StringDescription()
                .appendValue(Boolean.valueOf(_isBusy_2))
                .toString()
            + "\n     subject is "
            + new org.hamcrest.StringDescription().appendValue(this.subject).toString()
            + "\n",
        Should.<Boolean>operator_doubleArrow(Boolean.valueOf(_isBusy_2), false));
  }
 @Test
 @Named("returns the name for a step with resolved reference")
 @Order(3)
 public void _returnsTheNameForAStepWithResolvedReference() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("Scenario: MyScenario 2");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("Given a step with a resolved reference");
   _builder.newLine();
   _builder.append("Scenario: MyScenario 1");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("Given a step with a resolved reference");
   _builder.newLine();
   _builder.append("\t\t");
   _builder.append("\"implementation\"");
   _builder.newLine();
   this.parseScenario(_builder);
   String _stepName = this.stepName();
   boolean _doubleArrow =
       Should.operator_doubleArrow(_stepName, "Given a step with a resolved reference");
   Assert.assertTrue(
       "\nExpected stepName => \"Given a step with a resolved reference\" but"
           + "\n     stepName is "
           + new StringDescription().appendValue(_stepName).toString()
           + "\n",
       _doubleArrow);
 }
  /**
   * If you want to express how an object should behave, you can use `should`. It passes if the
   * result of the left expression is equal to the result of the right expression. You can also use
   * `not` to assert that both expressions have different results. You have already seen the short
   * cut `=>` which has the same effect as `should be`.
   */
  @Test
  @Named("\\\'should\\\' and `=>`")
  @Order(11)
  public void _shouldAnd() throws Exception {
    boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(true), true);
    Assert.assertTrue(
        "\nExpected true should be true but"
            + "\n     true should be true is "
            + new StringDescription().appendValue(null).toString()
            + "\n",
        _should_be);

    boolean _doubleArrow =
        Should.operator_doubleArrow(Boolean.valueOf(false), Boolean.valueOf(false));
    Assert.assertTrue(
        "\nExpected false => false but"
            + "\n     false => false is "
            + new StringDescription().appendValue(_doubleArrow).toString()
            + "\n",
        _doubleArrow);

    int _plus = (1 + 1);
    boolean _should_be_1 = Should.should_be(Integer.valueOf(_plus), Integer.valueOf(1));
    Assert.assertFalse(
        "\nExpected 1 + 1 should not be 1 but"
            + "\n     1 + 1 is "
            + new StringDescription().appendValue(Integer.valueOf(_plus)).toString()
            + "\n",
        _should_be_1);

    int _plus_1 = (1 + 1);
    boolean _doubleArrow_1 =
        Should.operator_doubleArrow(Integer.valueOf(_plus_1), Integer.valueOf(2));
    Assert.assertTrue(
        "\nExpected 1 + 1 => 2 but"
            + "\n     1 + 1 is "
            + new StringDescription().appendValue(Integer.valueOf(_plus_1)).toString()
            + "\n",
        _doubleArrow_1);
  }
  @Test
  @Named("Receives progress from server")
  @Order(5)
  public void _receivesProgressFromServer() throws Exception {
    ArrayList<String> _responses = this.server.getResponses();
    _responses.add(this.progressMessage);
    ArrayList<String> _responses_1 = this.server.getResponses();
    _responses_1.add(this.responseMessage);
    this.subject.connect(this.ADDRESS, this.PORT);
    this.subject.<Response>sendRequest(Commands.ANY_COMMAND, this.callback);
    final Function1<WaitConfig, Boolean> _function =
        new Function1<WaitConfig, Boolean>() {
          public Boolean apply(final WaitConfig it) {
            Response _response = TcpClientSendingRequestsSpec.this.callback.getResponse();
            return Boolean.valueOf((!Objects.equal(_response, null)));
          }
        };
    Wait.waitUntil(_function);
    List<Progress> _progress = this.callback.getProgress();
    int _size = _progress.size();
    boolean _doubleArrow =
        Should.<Integer>operator_doubleArrow(Integer.valueOf(_size), Integer.valueOf(1));
    Assert.assertTrue(
        "\nExpected callback.progress.size => 1 but"
            + "\n     callback.progress.size is "
            + new org.hamcrest.StringDescription().appendValue(Integer.valueOf(_size)).toString()
            + "\n     callback.progress is "
            + new org.hamcrest.StringDescription().appendValue(_progress).toString()
            + "\n     callback is "
            + new org.hamcrest.StringDescription().appendValue(this.callback).toString()
            + "\n",
        _doubleArrow);

    Response _response = this.callback.getResponse();
    final Procedure1<Response> _function_1 =
        new Procedure1<Response>() {
          public void apply(final Response it) {
            String _type = it.getType();
            Assert.assertTrue(
                "\nExpected type => \"response\" but"
                    + "\n     type is "
                    + new org.hamcrest.StringDescription().appendValue(_type).toString()
                    + "\n",
                Should.<String>operator_doubleArrow(_type, "response"));
          }
        };
    ObjectExtensions.<Response>operator_doubleArrow(_response, _function_1);
  }
 @Test
 @Named("uses referenced type")
 @Order(4)
 public void _usesReferencedType() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("describe org.junit.Assert{}");
   this._modelStore.parseSpec(_builder);
   String _qualifiedName = this.qualifiedName();
   boolean _doubleArrow = Should.operator_doubleArrow(_qualifiedName, "Assert");
   Assert.assertTrue(
       "\nExpected qualifiedName => \"Assert\" but"
           + "\n     qualifiedName is "
           + new StringDescription().appendValue(_qualifiedName).toString()
           + "\n",
       _doubleArrow);
 }
 @Test
 @Named("trims spec description whitespace")
 @Order(3)
 public void _trimsSpecDescriptionWhitespace() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("describe \"My Spec  \"{}");
   this._modelStore.parseSpec(_builder);
   String _qualifiedName = this.qualifiedName();
   boolean _doubleArrow = Should.operator_doubleArrow(_qualifiedName, "My Spec");
   Assert.assertTrue(
       "\nExpected qualifiedName => \"My Spec\" but"
           + "\n     qualifiedName is "
           + new StringDescription().appendValue(_qualifiedName).toString()
           + "\n",
       _doubleArrow);
 }
 @Test
 @Named("implementedStep.isPending[] should be false")
 @Order(2)
 public void _implementedStepIsPendingShouldBeFalse() throws Exception {
   Given _implementedStep = Features.implementedStep();
   boolean _isPending = _implementedStep.isPending();
   boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), false);
   Assert.assertTrue(
       "\nExpected implementedStep.isPending() should be false but"
           + "\n     implementedStep.isPending() is "
           + new StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()
           + "\n     implementedStep is "
           + new StringDescription().appendValue(_implementedStep).toString()
           + "\n",
       _should_be);
 }
 @Test
 @Named("stepWithoutImplementation.isPending[] should be true")
 @Order(1)
 public void _stepWithoutImplementationIsPendingShouldBeTrue() throws Exception {
   Given _stepWithoutImplementation = Features.stepWithoutImplementation();
   boolean _isPending = _stepWithoutImplementation.isPending();
   boolean _should_be = Should.<Boolean>should_be(Boolean.valueOf(_isPending), true);
   Assert.assertTrue(
       "\nExpected stepWithoutImplementation.isPending() should be true but"
           + "\n     stepWithoutImplementation.isPending() is "
           + new StringDescription().appendValue(Boolean.valueOf(_isPending)).toString()
           + "\n     stepWithoutImplementation is "
           + new StringDescription().appendValue(_stepWithoutImplementation).toString()
           + "\n",
       _should_be);
 }
Esempio n. 10
0
 @Test
 @Named("Root Specs pass")
 @Order(3)
 public void _rootSpecsPass() throws Exception {
   IEObjectDescription _rootSpec = this.rootSpec();
   boolean _apply = this.subject.apply(_rootSpec);
   boolean _doubleArrow =
       Should.operator_doubleArrow(Boolean.valueOf(_apply), Boolean.valueOf(true));
   Assert.assertTrue(
       "\nExpected subject.apply(rootSpec) => true but"
           + "\n     subject.apply(rootSpec) is "
           + new StringDescription().appendValue(Boolean.valueOf(_apply)).toString()
           + "\n     subject is "
           + new StringDescription().appendValue(this.subject).toString()
           + "\n     rootSpec is "
           + new StringDescription().appendValue(_rootSpec).toString()
           + "\n",
       _doubleArrow);
 }
Esempio n. 11
0
 @Test
 @Named("Child Specs fail")
 @Order(4)
 public void _childSpecsFail() throws Exception {
   IEObjectDescription _childSpec = this.childSpec();
   boolean _apply = this.subject.apply(_childSpec);
   boolean _doubleArrow =
       Should.operator_doubleArrow(Boolean.valueOf(_apply), Boolean.valueOf(false));
   Assert.assertTrue(
       "\nExpected subject.apply(childSpec) => false but"
           + "\n     subject.apply(childSpec) is "
           + new StringDescription().appendValue(Boolean.valueOf(_apply)).toString()
           + "\n     subject is "
           + new StringDescription().appendValue(this.subject).toString()
           + "\n     childSpec is "
           + new StringDescription().appendValue(_childSpec).toString()
           + "\n",
       _doubleArrow);
 }
Esempio n. 12
0
 @Test
 @Named("Features pass")
 @Order(2)
 public void _featuresPass() throws Exception {
   EClass _feature = this._featurePackage.getFeature();
   IEObjectDescription _desc = this.desc(_feature);
   boolean _apply = this.subject.apply(_desc);
   boolean _doubleArrow =
       Should.operator_doubleArrow(Boolean.valueOf(_apply), Boolean.valueOf(true));
   Assert.assertTrue(
       "\nExpected subject.apply(desc(feature)) => true but"
           + "\n     subject.apply(desc(feature)) is "
           + new StringDescription().appendValue(Boolean.valueOf(_apply)).toString()
           + "\n     subject is "
           + new StringDescription().appendValue(this.subject).toString()
           + "\n     desc(feature) is "
           + new StringDescription().appendValue(_desc).toString()
           + "\n     feature is "
           + new StringDescription().appendValue(_feature).toString()
           + "\n",
       _doubleArrow);
 }
 @Test
 @Named("keeps parameter values")
 @Order(5)
 public void _keepsParameterValues() throws Exception {
   StringConcatenation _builder = new StringConcatenation();
   _builder.append("Scenario: MyScenario 2");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("Given a step with two values \"a\" and \"b\"");
   _builder.newLine();
   _builder.append("\t ");
   _builder.append("1 + 1 => 2");
   _builder.newLine();
   this.parseScenario(_builder);
   String _stepName = this.stepName();
   boolean _doubleArrow =
       Should.operator_doubleArrow(_stepName, "Given a step with two values \"a\" and \"b\"");
   Assert.assertTrue(
       "\nExpected stepName => \'Given a step with two values \"a\" and \"b\"\' but"
           + "\n     stepName is "
           + new StringDescription().appendValue(_stepName).toString()
           + "\n",
       _doubleArrow);
 }