Skip to content

Commit

Permalink
sonar warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
oboehm committed Jul 13, 2017
1 parent 4d418f8 commit 5c1d680
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 9 deletions.
Expand Up @@ -19,6 +19,8 @@

import org.apache.commons.lang3.*;

import java.io.*;

/**
* Die InvalidValueException ist eine Exception fuer ungueltige Werte.
*
Expand All @@ -27,7 +29,7 @@
*/
public class InvalidValueException extends LocalizedValidationException {

private final Object value;
private final Serializable value;
private final String context;
private final Range<? extends Comparable> range;

Expand All @@ -49,7 +51,7 @@ public InvalidValueException(String context) {
* @param value der fehlerhafte Wert
* @param context Resource des fehlerhaften Wertes (z.B. "email_address")
*/
public InvalidValueException(Object value, String context) {
public InvalidValueException(Serializable value, String context) {
super("invalid value for " + context.replace('_', ' ') + ": \"" + value + '"');
this.value = value;
this.context = context;
Expand All @@ -64,7 +66,7 @@ public InvalidValueException(Object value, String context) {
* @param context Resource des fehlerhaften Wertes (z.B. "email_address")
* @param range untere und obere Schranke
*/
public InvalidValueException(Object value, String context, Range<? extends Comparable> range) {
public InvalidValueException(Serializable value, String context, Range<? extends Comparable> range) {
super("value for " + context.replace('_', ' ') + " is not in " + range + ": \"" + value + '"');
this.value = value;
this.context = context;
Expand Down
Expand Up @@ -32,7 +32,7 @@
*/
public abstract class LocalizedValidationException extends ValidationException {

private final ResourceBundle bundle = ResourceBundle.getBundle("de.jfachwert.messages");
private transient ResourceBundle bundle = ResourceBundle.getBundle("de.jfachwert.messages");

/**
* Erzeugt eine {@link LocalizedValidationException}.
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/de/jfachwert/FachwertTest.java
Expand Up @@ -17,12 +17,12 @@
*/
package de.jfachwert;

import de.jfachwert.bank.BIC;
import de.jfachwert.steuer.Steuernummer;
import org.junit.Test;
import de.jfachwert.bank.*;
import de.jfachwert.steuer.*;
import org.junit.*;

import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

/**
* Hier sind einige Tests versammelt, um allgemeine Dinge fuer die
Expand Down
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2017 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 13.07.2017 by oboehm (ob@oasd.de)
*/
package de.jfachwert.pruefung;

import org.junit.*;
import patterntesting.runtime.junit.*;

import java.io.*;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

/**
* Unit-Tests fuer {@link LocalizedValidationException}-Klasse.
*
* @author oboehm
*/
public final class LocalizedValidationExceptionTest {

private final LocalizedValidationException exception = new InvalidValueException("number");

/**
* Hier testen wir, ob eine lokalisierte Message zurueckkommt.
*/
@Test
public void getLocalizedString() {
String s = exception.getLocalizedMessage();
assertThat(s, not(isEmptyOrNullString()));
}

/**
* Da Exceptions serialisierbar sind, testen wir hier das.
*
* @throws NotSerializableException falls Exception nicht serialisierbar
*/
@Test
public void testSerializable() throws NotSerializableException {
SerializableTester.assertSerialization(exception);
}

}

0 comments on commit 5c1d680

Please sign in to comment.