From e6741fd092fecad0d9e5864e8af3d27ba7f571d8 Mon Sep 17 00:00:00 2001 From: JPANZO Date: Thu, 17 Feb 2022 15:31:27 +0100 Subject: [PATCH] Method loadCDWechseler of CDPlayer tested on leadingFirstCD -> CDListOfCDWechselerShouldHaveLength1. --- src/main/java/device/cdPlayer/CDPlayer.java | 6 ++++-- src/main/java/device/cdPlayer/CDWechseler.java | 9 ++++++++- src/test/java/device/cdPlayer/CDPlayerTest.java | 9 ++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/device/cdPlayer/CDPlayer.java b/src/main/java/device/cdPlayer/CDPlayer.java index da243d6..7e78148 100644 --- a/src/main/java/device/cdPlayer/CDPlayer.java +++ b/src/main/java/device/cdPlayer/CDPlayer.java @@ -148,6 +148,7 @@ public class CDPlayer implements Device { if(!(this.supportedFormats.contains(cd.getFormat()))){ throw new FormatNotSupportedException(); } + cdWechseler.loadOneCD(cd); } //Getters, Setters und SupportMethods @@ -197,6 +198,7 @@ public class CDPlayer implements Device { return this.loadedCD; } - - + public CDWechseler getCdWechseler() { + return cdWechseler; + } } diff --git a/src/main/java/device/cdPlayer/CDWechseler.java b/src/main/java/device/cdPlayer/CDWechseler.java index 1f408b1..40caf90 100644 --- a/src/main/java/device/cdPlayer/CDWechseler.java +++ b/src/main/java/device/cdPlayer/CDWechseler.java @@ -1,9 +1,10 @@ package device.cdPlayer; +import java.util.ArrayList; import java.util.List; public class CDWechseler { - private ListCDList; + private ListCDList=new ArrayList<>(); private boolean running=false; @@ -15,5 +16,11 @@ public class CDWechseler { this.running = true; } + public List getCDList() { + return CDList; + } + public void loadOneCD(CD cd){ + CDList.add(cd); + } } diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index d093081..81f79d6 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -401,6 +401,12 @@ class CDPlayerTest { Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.loadCDWechseler(cd)); assertEquals(FormatNotSupportedException.class, newException.getClass()); } + if(cases.equals("Case3")) { + _cdPlayer.changePlaySource(); + _cdPlayer.loadCDWechseler(cd); + int length=_cdPlayer.getCdWechseler().getCDList().size(); + assertThat(length).describedAs(testName).isEqualTo(1); + } } static Stream loadCDWechselerData () { CDPlayer cdPlayer1 = new CDPlayer(); @@ -411,7 +417,8 @@ class CDPlayerTest { CD DVD=new CD("DVD",videoPlayList); return Stream.of( Arguments.of("[loadCDWechseler() by notRunning=CDWechseler ] => shouldThrowAnException", "Case1", cdPlayer1,audioCD1,new CDWechselerNotRunningException()), - Arguments.of("[loadCDWechseler() by WrongCDFormat ] => shouldThrowAnException", "Case2", cdPlayer1,DVD,new FormatNotSupportedException()) + Arguments.of("[loadCDWechseler() by WrongCDFormat ] => shouldThrowAnException", "Case2", cdPlayer1,DVD,new FormatNotSupportedException()), + Arguments.of("[loadCDWechseler() by leadingFirstCD ] => CDListOfCDWechselerShouldHaveLength1", "Case3", cdPlayer1,audioCD1,null) ); }