Examples of MByHaveException


Examples of org.moresbycoffee.have.exceptions.MByHaveException

                LOG.fine("Parameter: " + param);
                LOG.fine("Position:  " + posInStepPattern);
               
                /* Check there is only one appearance in the stepPattern. */
                if (posInStepPattern < 0) {
                    throw new MByHaveException("The pattern does not contain placeholder for the " + param.getName() + " parameter in the step definition: " + stepValue);
                }
                if (stepValue.indexOf(paramPlaceHolder, posInStepPattern + param.getName().length()) >= 0) {
                    throw new MByHaveException("The pattern does contain more than one placeholder for the " + param + " parameter");
                }

                /* Add to the map. */
                result.put(Integer.valueOf(posInStepPattern), new MethodParameter(param.getName(), i, param.getType()));
            }
View Full Code Here

Examples of org.moresbycoffee.have.exceptions.MByHaveException

            if (storyIs != null) {
                return storyIs;
            }
        }

        throw new MByHaveException("The story file is not found. " + storyFile);

    }
View Full Code Here

Examples of org.moresbycoffee.have.exceptions.MByHaveException

                final InputStream storyIs = loadResource(storyFile, testClass);
                org.moresbycoffee.have.domain.Story storyObject;
                try {
                    storyObject = parseStory(storyFile, storyIs);
                } catch (final IOException e) {
                    throw new MByHaveException("The story file is not readable. " + storyFile, e);
                } finally {
                    try {
                        storyIs.close();
                    } catch (final IOException e) {
                        //TODO something
View Full Code Here

Examples of org.moresbycoffee.have.exceptions.MByHaveException

            if (line.startsWith("Scenario")) {
                if (scenarioBuilder == null) {
                    scenarioBuilder = new StringBuilder(line);
                    parseDescription = true;
                } else {
                    throw new MByHaveException("This scenario contains two scenario descriptions.");
                }
            } else if (line.startsWith("Given") || line.startsWith("When") || line.startsWith("Then")) {
                if (parseDescription) {
                    scenarioDescription = scenarioBuilder.toString();
                    scenarioBuilder = new StringBuilder(line);
                    parseDescription = false;
                } else if (scenarioBuilder != null) {
                    steps.add(scenarioBuilder.toString());
                    scenarioBuilder = new StringBuilder(line);
                } else {
                    scenarioDescription = "Scenario"; //Default scenario description
                    scenarioBuilder = new StringBuilder(line);
                }
            } else if (scenarioBuilder != null) {
                scenarioBuilder.append(line + "\n");
            }
        }
        if (scenarioBuilder != null) {
            if (parseDescription) {
                throw new MByHaveException("The scenario description does not contain any step description"); //TODO get the scenario description from somewhere.
            }
            steps.add(scenarioBuilder.toString());
        }
        return new Scenario(scenarioDescription, steps);
    }
View Full Code Here

Examples of org.moresbycoffee.have.exceptions.MByHaveException

                        Container container = Container.class.getDeclaredConstructor(Type.class).newInstance(param.getType());
                        containerMap.put(paramValue, container);
                        paramObject = container;
                    } catch (Exception e) {
                        /* This exception should not occur ever. */
                        throw new MByHaveException("Container object can't be instantiated.", e);
                    }
                }
            } else {
                paramObject = paramValue;
            }
View Full Code Here

Examples of org.moresbycoffee.have.exceptions.MByHaveException

    private Object invokeMethod(final Method method, final Object target, final Object... parameters) {
        try {
            return method.invoke(target, parameters);
        } catch (final IllegalArgumentException e) {
            throw new MByHaveException("The parameters could not be matched.", e);
        } catch (final IllegalAccessException e) {
            throw new MByHaveException("The annotated method should be public.", e);
        } catch (final InvocationTargetException e) {
            if (e.getTargetException() instanceof AssertionError) {
                throw (AssertionError) e.getTargetException();
            }
            throw new MByHaveException(e);
        }
    }
View Full Code Here

Examples of org.moresbycoffee.have.exceptions.MByHaveException

    private MByHave(final Object testObject, final Class<?> stepClass) throws MByHaveException {
        this.testObject = testObject;
        try {
            this.runner     = new MByHaveRunner(stepClass, false);
        } catch (final InitializationError e) {
            throw new MByHaveException("The mByHave initailization did not succeed", e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.