first test check second NullPointException dont now why
parent
b59001b2ab
commit
c119b04864
|
@ -3,15 +3,15 @@ package de.hs_mannheim.informatik.bank.domain;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Kunde implements Serializable{
|
||||
|
||||
public class Kunde implements Serializable {
|
||||
|
||||
private static int id = 0;
|
||||
private String vorname;
|
||||
private String name;
|
||||
private int alter;
|
||||
private String wohnort;
|
||||
private ArrayList<Konto> konten;
|
||||
|
||||
|
||||
public Kunde(String vorname, String name, int alter, String wohnort) {
|
||||
this.vorname = vorname;
|
||||
this.name = name;
|
||||
|
@ -19,22 +19,39 @@ public class Kunde implements Serializable{
|
|||
this.wohnort = wohnort;
|
||||
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) {
|
||||
konten.add(k);
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Konto> getKonten() {
|
||||
return konten;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue