All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.jsimpletools.Errors Maven / Gradle / Ivy

There is a newer version: 0.3.1
Show newest version
/*
 * #%L
 * jSimpleTools
 * %%
 * Copyright (C) 2011 - 2015 Eric-Karl Matteau 
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */
package net.sf.jsimpletools;


public enum Errors {

    /*
     * Context Errors.
     */
    OBJECT_NOT_OF_KEY_TYPE("The Object to place in context must"
            + " be an instance of the injection key class or its subclass"),

    CANNOT_ADD_NULL_TO_CONTEXT("Null objects cannot be placed in context."),

    MOCKER_NOT_SET("The mocker object must be set before"
            + " attempting to use the mock() method. Set it using the useMocker() method."),

    CANNOT_ADD_CONTEXT_TO_CONTEXT(
            "The context object cannot be added to context or wired using context."),

    FILTER_EXCEPTION("Error while applying filter (%s)\nto context: %s. %s "),

    MANDATORY_FILTER("Filter is mandatory:%s"),

    FIELD_INJECTION_FAILED("Could not inject field [%s], into object [%s]. \nCause: %s"),

    CANNOT_MODIFY_INJECTION_UNIT_ONCE_WIRED(
            "Injection Units cannot be changed once wired into context."),

    RULE_COMPONENT_MUST_NOT_BE_NULL("%s rule component must be provided, it cannot be null"),

    /*
     * Replicator Errors.
     */
    REPLICATOR_RETURNED_SAME_INSTANCE(
            "Post-condition check failed: %s replicator returned same instance."),

    REPLICATOR_RETURNED_DIFFERENT_TYPE(
            "Post-condition check failed: %s replicator returned object of type %s, expected %s."),

    REPLICATOR_EXCEPTION_THROWN_BY_INNER_CALL(
            "Replication failed: call to %s.replicate() threw an error."),

    REPLICATOR_UNHANDLED_TYPE("Could not find specific Replicator for: %s."),

    /*
     * Sequence Errors.
     */
    SEQUENCE_MAX_VALUE_REACHED("Maximum value for %s sequence has been reached."),

    GENERATED_STRING_NOT_MATCHING(
            "Failed to generate random string from provided regex. Please, keep in mind "
                    + "that only simple regular expressions are supported. \nRequested: \"%s\", "
                    + "what was generated: \"%s\".\n"
                    + "The reason you are seeing this message is probably because your are using a "
                    + "regular expression that is more complex than what is implemented in the "
                    + "generator. \nThe generator will always validate generated strings against "
                    + "the requested regular expression. This ensures that the generated string "
                    + "will always be a match for the regex."),

    FAILED_GENERATING_UNIQUE_STRING(
            "Could not generate unique string after %d attempts. Requested: \"%s\".");

    ;

    private String message;

    Errors(String message) {
        this.message = message;
    }

    String getFormattedMessage(Object... params) {
        return String.format(message, params);
    }

    public SimpleTestToolsException exception(Object... params) {
        return exception(/* cause */null, params);
    }

    public SimpleTestToolsException exception(Throwable cause, Object... params) {
        return new SimpleTestToolsException(cause, this, params);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy