Package br.com.caelum.stella

Examples of br.com.caelum.stella.MessageProducer


public class CoreExample {
  public static void main(String[] args) {
    String cnpj = "26.637.142/0001-48";
    ResourceBundle resourceBundle = ResourceBundle
        .getBundle("StellaValidationMessages",new Locale("pt","BR"));
    MessageProducer messageProducer = new ResourceBundleMessageProducer(
        resourceBundle);
    boolean isFormatted = true;
    CNPJValidator validator = new CNPJValidator(messageProducer,
        isFormatted);
    try {
View Full Code Here


public class BaseValidatorTest {

    @Test
    public void testGetValidationMessagesT() {
        Mockery mockery = new Mockery();
        final MessageProducer messageProducer = mockery.mock(MessageProducer.class);
        final InvalidValue invalidValue = mockery.mock(InvalidValue.class);
        final ValidationMessage validationMessage = mockery.mock(ValidationMessage.class);

        mockery.checking(new Expectations() {
            {
View Full Code Here

    }

    @Test
    public void testAssertValidShouldThrowInvalidStateExpectionWhenComesAnInvalidValue() {
        Mockery mockery = new Mockery();
        final MessageProducer messageProducer = mockery.mock(MessageProducer.class);
        final InvalidValue invalidValue = mockery.mock(InvalidValue.class);
        final ValidationMessage validationMessage = mockery.mock(ValidationMessage.class);

        mockery.checking(new Expectations() {
            {
View Full Code Here

    }

    @Test
    public void testAssertValidShouldNotThrowInvalidStateExpectionWhenValueIsValid() {
        Mockery mockery = new Mockery();
        final MessageProducer messageProducer = mockery.mock(MessageProducer.class);

        mockery.checking(new Expectations());
        BaseValidator validator = new BaseValidator(messageProducer);
        try {
            List<InvalidValue> invalidValues = new ArrayList<InvalidValue>();
View Full Code Here

    }

    @Test
    public void shouldReturnCorrectValidationMessage() {
        Mockery mockery = new Mockery();
        final MessageProducer messageProducer = mockery.mock(MessageProducer.class);
        LengthValidator lengthValidator = new LengthValidator(messageProducer, 2);
        String message = "O tamanho da entrada é inválido.";
        final ValidationMessage validationMessage = new SimpleValidationMessage(message);
        mockery.checking(new Expectations() {
            {
View Full Code Here

public class CoreExample {
    public static void main(String[] args) {
        String cnpj = "26.637.142/0001-48";
        ResourceBundle resourceBundle = ResourceBundle.getBundle("StellaValidationMessages", new Locale("pt", "BR"));
        MessageProducer messageProducer = new ResourceBundleMessageProducer(resourceBundle);
        boolean isFormatted = true;
        CNPJValidator validator = new CNPJValidator(messageProducer, isFormatted);
        try {
            // lógica de negócio ...
            validator.assertValid(cnpj);
View Full Code Here

TOP

Related Classes of br.com.caelum.stella.MessageProducer

Copyright © 2018 www.massapicom. 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.