Fix fileEncoding violations for checkstyle
[groupbasedpolicy.git] / groupbasedpolicy / src / test / java / org / opendaylight / groupbasedpolicy / resolver / validator / ValidationResultTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.groupbasedpolicy.resolver.validator;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14
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;
21
22 public class ValidationResultTest {
23
24     @Rule
25     public ExpectedException thrown = ExpectedException.none();
26
27     public static final String VALIDATED = "Validated.";
28     public static final String EMPTY_STRING = "";
29
30     ValidationResultBuilder resultBuilder;
31
32     @Before
33     public void init() {
34         resultBuilder = new ValidationResultBuilder();
35     }
36
37     @Test
38     public void testBuild_WithSuccess() {
39         ValidationResult result = resultBuilder.success().build();
40         assertTrue(result.isValid());
41         assertEquals(EMPTY_STRING, result.getMessage());
42     }
43
44     @Test
45     public void testBuild_WithFailed() {
46         ValidationResult result = resultBuilder.failed().build();
47         assertFalse(result.isValid());
48         assertEquals(EMPTY_STRING, result.getMessage());
49     }
50
51     @Test
52     public void testMessage() {
53         ValidationResult result = resultBuilder.setMessage(VALIDATED).build();
54
55         assertEquals(VALIDATED, result.getMessage());
56
57         thrown.expect(IllegalArgumentException.class);
58         thrown.expectMessage(ValidationResultBuilder.ILLEGAL_ARG_EX_MSG);
59         resultBuilder.setMessage(null);
60     }
61
62 }