/*
 * Copyright 2017 Viktor Csomor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.viktorc.pp4j.impl;

import org.junit.Assert;
import org.junit.Test;

/**
 * A unit test class for {@link SimpleCommand}.
 *
 * @author Viktor Csomor
 */
public class SimpleCommandTest extends TestCase {

  @Test
  public void testGeneratesOutputFalseWhenNoCompletionPredicatesDefined() {
    SimpleCommand command = new SimpleCommand("");
    Assert.assertFalse(command.generatesOutput());
  }

  @Test
  public void testGeneratesOutputTrueWhenCompletionPredicatesDefined() {
    SimpleCommand command = new SimpleCommand("", (c, o) -> true, (c, o) -> false);
    Assert.assertTrue(command.generatesOutput());
  }

  @Test
  public void testThrowsExceptionWhenInstructionNull() {
    exceptionRule.expect(IllegalArgumentException.class);
    new SimpleCommand(null);
  }

  @Test
  public void testThrowsExceptionWhenPredicateNull() {
    exceptionRule.expect(IllegalArgumentException.class);
    new SimpleCommand("", (c, o) -> true, null);
  }

}

@@ -622,16 +622,91 @@
 .impl;%0A%0A
+import java.util.List;%0Aimport net.viktorc.pp4j.api.FailedCommandException;%0A
 import o
@@ -1624,10 +1624,1957 @@
 );%0A  %7D%0A%0A
+  @Test%0A  public void testIsCompletedThrowsExceptionWhenStdErrPredicateNotDefined() throws FailedCommandException %7B%0A    SimpleCommand command = new SimpleCommand(%22%22, (c, o) -%3E true);%0A    exceptionRule.expect(FailedCommandException.class);%0A    command.isCompleted(%22%22, true);%0A  %7D%0A%0A  @Test%0A  public void testIsCompletedReturnsTrueIfPredicateDoes() throws FailedCommandException %7B%0A    SimpleCommand command = new SimpleCommand(%22%22, (c, o) -%3E %22done%22.equals(o), (c, o) -%3E %22error%22.equals(o));%0A    Assert.assertFalse(command.isCompleted(%22error%22, false));%0A    Assert.assertFalse(command.isCompleted(%22%22, false));%0A    Assert.assertTrue(command.isCompleted(%22done%22, false));%0A    Assert.assertFalse(command.isCompleted(%22done%22, true));%0A    Assert.assertFalse(command.isCompleted(%22%22, true));%0A    Assert.assertTrue(command.isCompleted(%22error%22, true));%0A  %7D%0A%0A  @Test%0A  public void testSavesProcessOutputCorrectly() throws FailedCommandException %7B%0A    SimpleCommand command = new SimpleCommand(%22%22, (c, o) -%3E true, (c, o) -%3E true);%0A    command.isCompleted(%221%22, false);%0A    command.isCompleted(%22dog%22, true);%0A    command.isCompleted(%222%22, false);%0A    command.isCompleted(%22cat%22, false);%0A    command.isCompleted(%223%22, true);%0A    List%3CString%3E stdOutLines = command.getStandardOutLines();%0A    List%3CString%3E stdErrLines = command.getStandardErrLines();%0A    String jointStdOutLines = command.getJointStandardOutLines();%0A    String jointStdErrLines = command.getJointStandardErrLines();%0A    Assert.assertEquals(3, stdOutLines.size());%0A    Assert.assertEquals(2, stdErrLines.size());%0A    Assert.assertEquals(%221%22, stdOutLines.get(0));%0A    Assert.assertEquals(%222%22, stdOutLines.get(1));%0A    Assert.assertEquals(%22cat%22, stdOutLines.get(2));%0A    Assert.assertEquals(%22dog%22, stdErrLines.get(0));%0A    Assert.assertEquals(%223%22, stdErrLines.get(1));%0A    Assert.assertEquals(String.format(%221%25n2%25ncat%22), jointStdOutLines);%0A    Assert.assertEquals(String.format(%22dog%25n3%22), jointStdErrLines);%0A  %7D%0A%0A
 %7D%0A

Add more tests