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.renderer.ofoverlay.sf;
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;
16 import java.util.Collections;
17 import java.util.List;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
23 public class ClassificationResultTest {
25 private List<MatchBuilder> matches;
26 private String errorMessage = "errorMessage";
30 MatchBuilder matchBuilder = mock(MatchBuilder.class);
31 matches = Collections.singletonList(matchBuilder);
35 public void testGetMatchBuilders_Success() {
36 ClassificationResult result = new ClassificationResult(matches);
37 assertEquals(matches, result.getMatchBuilders());
40 @Test(expected = IllegalStateException.class)
41 public void testGetMatchBuilders_Failure() {
42 ClassificationResult result = new ClassificationResult(errorMessage);
43 result.getMatchBuilders();
47 public void testGetErrorMessage() {
48 ClassificationResult result1 = new ClassificationResult(errorMessage);
49 assertEquals(errorMessage, result1.getErrorMessage());
51 ClassificationResult result2 = new ClassificationResult(matches);
52 assertTrue(result2.getErrorMessage().isEmpty());
56 public void testIsSuccessfull() {
57 ClassificationResult result1 = new ClassificationResult(errorMessage);
58 assertFalse(result1.isSuccessfull());
60 ClassificationResult result2 = new ClassificationResult(matches);
61 assertTrue(result2.isSuccessfull());