ExecutableWithDescriptor { boolean isLastExecutable() { final RobotExecutableRow<?> executable = getExecutable(); final Object parent = executable.getParent(); final List<? extends RobotExecutableRow<?>> allElements = parent instanceof TestCase ? ((TestCase) parent).getExecutionContext() : ((UserKeyword) parent).getExecutionContext(); return allElements.get(allElements.size() - 1) == executable; } ExecutableWithDescriptor(final RobotExecutableRow<?> executable, final IExecutableRowDescriptor<?> descriptor,
            final String template);   ExecutableWithDescriptor(final ForLoop loopExecutable, final String template);   }
@Test public void checkingLastExecutableForTestCase() { final RobotExecutableRow<TestCase> firstExecutable = new RobotExecutableRow<>(); final RobotExecutableRow<TestCase> secondExecutable = new RobotExecutableRow<>(); final RobotExecutableRow<TestCase> thirdExecutable = new RobotExecutableRow<>(); final TestCase testCase = new TestCase(RobotToken.create("test")); testCase.addElement(firstExecutable); testCase.addElement(secondExecutable); testCase.addElement(thirdExecutable); final ExecutableWithDescriptor firstExecWithDescriptor = new ExecutableWithDescriptor(firstExecutable, mock(IExecutableRowDescriptor.class), null); final ExecutableWithDescriptor secondExecWithDescriptor = new ExecutableWithDescriptor(secondExecutable, mock(IExecutableRowDescriptor.class), null); final ExecutableWithDescriptor thirdExecWithDescriptor = new ExecutableWithDescriptor(thirdExecutable, mock(IExecutableRowDescriptor.class), null); assertThat(firstExecWithDescriptor.isLastExecutable()).isFalse(); assertThat(secondExecWithDescriptor.isLastExecutable()).isFalse(); assertThat(thirdExecWithDescriptor.isLastExecutable()).isTrue(); }
@Test public void checkingLastExecutableForUserKeyword() { final RobotExecutableRow<UserKeyword> firstExecutable = new RobotExecutableRow<>(); final RobotExecutableRow<UserKeyword> secondExecutable = new RobotExecutableRow<>(); final RobotExecutableRow<UserKeyword> thirdExecutable = new RobotExecutableRow<>(); final UserKeyword keyword = new UserKeyword(RobotToken.create("keyword")); keyword.addElement(firstExecutable); keyword.addElement(secondExecutable); keyword.addElement(thirdExecutable); final ExecutableWithDescriptor firstExecWithDescriptor = new ExecutableWithDescriptor(firstExecutable, mock(IExecutableRowDescriptor.class), null); final ExecutableWithDescriptor secondExecWithDescriptor = new ExecutableWithDescriptor(secondExecutable, mock(IExecutableRowDescriptor.class), null); final ExecutableWithDescriptor thirdExecWithDescriptor = new ExecutableWithDescriptor(thirdExecutable, mock(IExecutableRowDescriptor.class), null); assertThat(firstExecWithDescriptor.isLastExecutable()).isFalse(); assertThat(secondExecWithDescriptor.isLastExecutable()).isFalse(); assertThat(thirdExecWithDescriptor.isLastExecutable()).isTrue(); }