BAEL-6221 Get Mocks from MockedConstruction in Mockito (#14776)
Co-authored-by: jcook02 <jonathan.paul.cook@ext.esa.int>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.construction;
|
||||
|
||||
public class CoffeeMachine {
|
||||
|
||||
private Grinder grinder;
|
||||
private WaterTank tank;
|
||||
|
||||
public CoffeeMachine() {
|
||||
this.grinder = new Grinder();
|
||||
this.tank = new WaterTank();
|
||||
}
|
||||
|
||||
public CoffeeMachine(int mils) {
|
||||
this.grinder = new Grinder();
|
||||
this.tank = new WaterTank(mils);
|
||||
}
|
||||
|
||||
public String makeCoffee() {
|
||||
String type = this.tank.isEspresso() ? "Espresso" : "Americano";
|
||||
return String.format("Finished making a delicious %s made with %s beans", type, this.grinder.getBeans());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.construction;
|
||||
|
||||
public class Fruit {
|
||||
|
||||
public String getName() {
|
||||
return "Apple";
|
||||
}
|
||||
|
||||
public String getColour() {
|
||||
return "Red";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.construction;
|
||||
|
||||
public class Grinder {
|
||||
|
||||
private String beans;
|
||||
|
||||
public Grinder() {
|
||||
this.beans = "Guatemalan";
|
||||
}
|
||||
|
||||
public String getBeans() {
|
||||
return beans;
|
||||
}
|
||||
|
||||
public void setBeans(String beans) {
|
||||
this.beans = beans;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.construction;
|
||||
|
||||
public class WaterTank {
|
||||
|
||||
private int mils;
|
||||
|
||||
public WaterTank() {
|
||||
this.mils = 25;
|
||||
}
|
||||
|
||||
public WaterTank(int mils) {
|
||||
this.mils = mils;
|
||||
}
|
||||
|
||||
public int getMils() {
|
||||
return mils;
|
||||
}
|
||||
|
||||
public void setMils(int mils) {
|
||||
this.mils = mils;
|
||||
}
|
||||
|
||||
public boolean isEspresso() {
|
||||
return getMils() < 50;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user