Browse Source

verkaufen now throws a exception if argument is illegal

Carsten Schöffel 6 months ago
parent
commit
df8ad5f302
3 changed files with 6 additions and 3 deletions
  1. 4 1
      pom.xml
  2. 1 1
      src/main/java/Aktie.java
  3. 1 1
      src/test/java/Test_Aktie.java

+ 4 - 1
pom.xml

@@ -3,7 +3,10 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
-
+    <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
+    </properties>
     <groupId>de.c4ne.jenkins</groupId>
     <artifactId>ciip-wise-19-dassystem</artifactId>
     <version>1.0-SNAPSHOT</version>

+ 1 - 1
src/main/java/Aktie.java

@@ -13,7 +13,7 @@ public class Aktie {
         }
 
         if (an == null) {
-            return;
+            throw new IllegalArgumentException("Argument 'an' should not be null");
         }
         this.inhaber = an;
     }

+ 1 - 1
src/test/java/Test_Aktie.java

@@ -59,7 +59,7 @@ public class Test_Aktie {
         //Act
         try {
             aktie.verkaufen(null);
-        } catch (AktieNotSalableException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }