AUsersthnDownloads Pokemon Trainer java Notepad. File Edit Search View Encoding
ID: 3748703 • Letter: A
Question
AUsersthnDownloads Pokemon Trainer java Notepad. File Edit Search View Encoding Language Settings Tools Macro Run Plugins Window ppened 1import java.util.Observer 2 import java.util.observable public clasa PokesonTrainer implements Myobserver f private 3tring myiame einvariant nyName 18 19 25 publie PokemonTrainer (string name) { myNane namei public string getHame O return yName 34 36 37 eoverride 42 public void update (Myobservable oba, Object O) string whatHappened whatHappened - this is notified thato System.out-print.in (whatHappened) 47 18 51 E blic String tostringO ( string returnval returnval"PokenonTrainer " myName return returnval 54 56 7end class PokemonTzainer 50Explanation / Answer
/*You should include below line in your code in ordder to verify void return method
PrintStream out = System.out;
*/
@Test
public void testUpdate(){
PokemanTrainer obj = new PokemanTrainer();
obj.out = Mockito.spy(new PrintStream(...));
// mock a call with an expected input
doNothing().when(obj.out).println("Pokemon notified");
obj.updateGreen();
// we need to test if there was a call
Mockito.verify(obj.out, Mockito.times(1)).println("Pokemon notified");
}
@Test
public void toStringTest()
{
PokemanTrainer obj = new PokemanTrainer();
assertThat(obj.toString(), contains("PokemonTrainer "));
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.