2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.resolver.validator;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
15 import org.junit.Before;
16 import org.junit.Rule;
17 import org.junit.Test;
18 import org.junit.rules.ExpectedException;
19 import org.opendaylight.groupbasedpolicy.api.ValidationResult;
20 import org.opendaylight.groupbasedpolicy.dto.ValidationResultBuilder;
22 public class ValidationResultTest {
25 public ExpectedException thrown = ExpectedException.none();
27 public static final String VALIDATED = "Validated.";
28 public static final String EMPTY_STRING = "";
30 ValidationResultBuilder resultBuilder;
34 resultBuilder = new ValidationResultBuilder();
38 public void testBuild_WithSuccess() {
39 ValidationResult result = resultBuilder.success().build();
40 assertTrue(result.isValid());
41 assertEquals(EMPTY_STRING, result.getMessage());
45 public void testBuild_WithFailed() {
46 ValidationResult result = resultBuilder.failed().build();
47 assertFalse(result.isValid());
48 assertEquals(EMPTY_STRING, result.getMessage());
52 public void testMessage() {
53 ValidationResult result = resultBuilder.setMessage(VALIDATED).build();
55 assertEquals(VALIDATED, result.getMessage());
57 thrown.expect(IllegalArgumentException.class);
58 thrown.expectMessage(ValidationResultBuilder.ILLEGAL_ARG_EX_MSG);
59 resultBuilder.setMessage(null);