b68f4a2d4e5c9cc893a622da709512422db34749
[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.mockito.Mockito.mock;
12
13 import java.util.Arrays;
14 import java.util.List;
15
16 import org.junit.Assert;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
20
21 public class ClassificationResultTest {
22
23     private ClassificationResult result;
24
25     private MatchBuilder matchBuilder;
26     private List<MatchBuilder> matches;
27     private String errorMessage = "errorMessage";
28
29     @Before
30     public void initialise() {
31         matchBuilder = mock(MatchBuilder.class);
32         matches = Arrays.asList(matchBuilder);
33     }
34
35     @Test
36     public void getMatchBuildersTestSuccess() {
37         result = new ClassificationResult(matches);
38         Assert.assertEquals(matches, result.getMatchBuilders());
39     }
40
41     @Test(expected = IllegalStateException.class)
42     public void getMatchBuildersTestFailure() {
43         result = new ClassificationResult(errorMessage);
44         result.getMatchBuilders();
45     }
46
47     @Test
48     public void getErrorMessageTest() {
49         result = new ClassificationResult(errorMessage);
50         Assert.assertEquals(errorMessage, result.getErrorMessage());
51         result = new ClassificationResult(matches);
52         Assert.assertTrue(result.getErrorMessage().isEmpty());
53     }
54
55     @Test
56     public void isSuccessfullTest() {
57         result = new ClassificationResult(errorMessage);
58         Assert.assertFalse(result.isSuccessfull());
59         result = new ClassificationResult(matches);
60         Assert.assertTrue(result.isSuccessfull());
61     }
62 }