Fix fileEncoding violations for checkstyle
[groupbasedpolicy.git] / renderers / ofoverlay / src / test / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / sf / ClassificationResultTest.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.renderer.ofoverlay.sf;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14 import static org.mockito.Mockito.mock;
15
16 import java.util.Collections;
17 import java.util.List;
18
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
22
23 public class ClassificationResultTest {
24
25     private List<MatchBuilder> matches;
26     private String errorMessage = "errorMessage";
27
28     @Before
29     public void init() {
30         MatchBuilder matchBuilder = mock(MatchBuilder.class);
31         matches = Collections.singletonList(matchBuilder);
32     }
33
34     @Test
35     public void testGetMatchBuilders_Success() {
36         ClassificationResult result = new ClassificationResult(matches);
37         assertEquals(matches, result.getMatchBuilders());
38     }
39
40     @Test(expected = IllegalStateException.class)
41     public void testGetMatchBuilders_Failure() {
42         ClassificationResult result = new ClassificationResult(errorMessage);
43         result.getMatchBuilders();
44     }
45
46     @Test
47     public void testGetErrorMessage() {
48         ClassificationResult result1 = new ClassificationResult(errorMessage);
49         assertEquals(errorMessage, result1.getErrorMessage());
50
51         ClassificationResult result2 = new ClassificationResult(matches);
52         assertTrue(result2.getErrorMessage().isEmpty());
53     }
54
55     @Test
56     public void testIsSuccessfull() {
57         ClassificationResult result1 = new ClassificationResult(errorMessage);
58         assertFalse(result1.isSuccessfull());
59
60         ClassificationResult result2 = new ClassificationResult(matches);
61         assertTrue(result2.isSuccessfull());
62     }
63 }