first test check second NullPointException dont now why

test
WummerMIB 2022-11-08 11:59:22 +01:00
parent b59001b2ab
commit c119b04864
2 changed files with 62 additions and 7 deletions

View File

@ -20,6 +20,22 @@ public class Kunde implements Serializable{
this.id++; this.id++;
} }
public String getVorname() {
return vorname;
}
public String getName() {
return name;
}
public int getAlter() {
return alter;
}
public String getWohnort() {
return wohnort;
}
public void kundeHatKonte(Konto k) { public void kundeHatKonte(Konto k) {
konten.add(k); konten.add(k);
} }
@ -34,7 +50,8 @@ public class Kunde implements Serializable{
@Override @Override
public String toString() { public String toString() {
return "Vorname: " + this.vorname + " Name: " + this.name +" Alter: " + this.alter + " Wohnort: "+ this.wohnort; return "Vorname: " + this.vorname + " Name: " + this.name + " Alter: " + this.alter + " Wohnort: "
+ this.wohnort;
} }
} }

View File

@ -0,0 +1,38 @@
package de.hs_mannheim.informatik.bank.domain;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import org.junit.jupiter.api.Test;
class KundeTest {
@Test
void testKontoBasic() {
Kunde k = new Kunde("TestVor","TestNam",20,"TestHeim");
assertEquals(1, k.getId());
assertEquals("TestVor", k.getVorname());
assertEquals("TestNam", k.getName());
assertEquals(20, k.getAlter());
assertEquals("TestHeim", k.getWohnort());
}
@Test
void testKundeHatKonto() {
Kunde ku = new Kunde("TestVor","TestNam",20,"TestHeim");
Konto ko = new Konto("TestKonto",1);
Konto gi = new Girokonto("TestGiro",2);
Konto de = new Depot("Testdep",3);
ku.kundeHatKonte(ko);
ku.kundeHatKonte(gi);
ku.kundeHatKonte(de);
ArrayList<Konto> konten = new ArrayList<>();
konten.add(ko);
konten.add(gi);
konten.add(de);
assertTrue(konten.equals(ku.getKonten()));
}
}