X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2FValidationExceptionTest.java;h=11b3f0be7e3a0ee688ebfd6178fe99214575644b;hp=8b4f2fe25875149bae70d0d80157961549939c80;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=e316a0ef36279a72767703d190f38a39d7d49395 diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java index 8b4f2fe258..11b3f0be7e 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.config.api; import static org.hamcrest.CoreMatchers.containsString; @@ -5,6 +13,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; + import com.google.common.collect.Lists; import java.util.Map; import org.junit.Assert; @@ -17,16 +26,18 @@ public class ValidationExceptionTest { private final String instance2 = "instance2"; private final ModuleIdentifier mi2 = new ModuleIdentifier("module", instance2); private final String message = "ex message"; - private final Exception e = new IllegalStateException(message); + private final Exception exception = new IllegalStateException(message); @Test public void testCreateFromCollectedValidationExceptions() throws Exception { - ValidationException single = ValidationException.createForSingleException(mi, e); - ValidationException single2 = ValidationException.createForSingleException(mi2, e); + ValidationException single = ValidationException.createForSingleException(mi, exception); + ValidationException single2 = ValidationException.createForSingleException(mi2, exception); - ValidationException collected = ValidationException.createFromCollectedValidationExceptions(Lists.newArrayList(single, single2)); + ValidationException collected = ValidationException + .createFromCollectedValidationExceptions(Lists.newArrayList(single, single2)); - Map> failedMap = collected.getFailedValidations(); + Map> failedMap = collected + .getFailedValidations(); assertEquals(1, failedMap.size()); assertTrue(failedMap.containsKey("module")); @@ -40,11 +51,11 @@ public class ValidationExceptionTest { @Test public void testCreateFromCollectedValidationExceptionsWithDuplicate() throws Exception { - ValidationException single = ValidationException.createForSingleException(mi, e); - ValidationException single2 = ValidationException.createForSingleException(mi, e); + ValidationException single = ValidationException.createForSingleException(mi, exception); + ValidationException single2 = ValidationException.createForSingleException(mi, exception); try { ValidationException.createFromCollectedValidationExceptions(Lists.newArrayList(single, single2)); - } catch (IllegalArgumentException ex) { + } catch (final IllegalArgumentException ex) { // Duplicate exception assertThat(ex.getMessage(), containsString("Cannot merge")); return; @@ -54,104 +65,112 @@ public class ValidationExceptionTest { @Test public void testGetTrace() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); - exp.setTrace("trace"); + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(); + exp.setStackTrace("trace"); Assert.assertEquals(exp.getTrace(), "trace"); } @Test public void testSetMessage() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(); exp.setMessage("message"); Assert.assertEquals(exp.getMessage(), "message"); } @Test public void testHashCode() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); + ValidationException.ExceptionMessageWithStackTrace exp = + new ValidationException.ExceptionMessageWithStackTrace(); Assert.assertEquals(exp.hashCode(), new ValidationException.ExceptionMessageWithStackTrace().hashCode()); } @Test public void testExceptionMessageWithStackTraceConstructor() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertEquals(exp, exp); } @Test public void testExceptionMessageWithStackTraceConstructor2() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, null); } @Test public void testExceptionMessageWithStackTraceConstructor3() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, new Exception()); } @Test public void testExceptionMessageWithStackTraceConstructor4() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertEquals(exp, new ValidationException.ExceptionMessageWithStackTrace("string1", "string2")); } @Test public void testEqual() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace(null, "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + null, "string2"); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual2() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("different", "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + "different", "string2"); Assert.assertNotEquals(exp, exp2); } - @Test public void testEqual3() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", null); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", null); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual4() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", "different"); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", "different"); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual5() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace(null, "string2"); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + null, "string2"); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, exp2); } @Test public void testEqual6() throws Exception { - ValidationException.ExceptionMessageWithStackTrace exp = - new ValidationException.ExceptionMessageWithStackTrace("string1", null); + ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace( + "string1", null); ValidationException.ExceptionMessageWithStackTrace exp2 = - new ValidationException.ExceptionMessageWithStackTrace("string1", "string2"); + new ValidationException.ExceptionMessageWithStackTrace( + "string1", "string2"); Assert.assertNotEquals(exp, exp2); } -} \ No newline at end of file +}