2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.groupbasedpolicy.resolver.validator;
\r
11 import org.junit.Assert;
\r
12 import org.junit.Before;
\r
13 import org.junit.Rule;
\r
14 import org.junit.Test;
\r
15 import org.junit.rules.ExpectedException;
\r
17 public class ValidationResultTest {
\r
20 public ExpectedException thrown = ExpectedException.none();
\r
22 ValidationResultBuilder resultBuilder;
\r
23 ValidationResult result;
\r
26 public void initialisation() {
\r
27 resultBuilder = new ValidationResultBuilder();
\r
31 public void successValidationTest() {
\r
32 result = resultBuilder.success().build();
\r
33 Assert.assertTrue(result.isValid());
\r
34 Assert.assertTrue(result.getMessage().equals(""));
\r
38 public void unsuccessValidationTest() {
\r
39 result = resultBuilder.failed().build();
\r
40 Assert.assertFalse(result.isValid());
\r
41 Assert.assertTrue(result.getMessage().equals(""));
\r
45 public void messageTest() {
\r
46 result = resultBuilder.setMessage("Validated.").build();
\r
47 Assert.assertTrue(result.getMessage().equals("Validated."));
\r
48 thrown.expect(IllegalArgumentException.class);
\r
49 thrown.expectMessage("Result message cannot be set to NULL!");
\r
50 resultBuilder.setMessage(null);
\r