Mandatory steps

Report a typo

You have a Cafe class that uses a SweetSupplier class to get different types of sweets.

Java
@Component
public class Cafe {

    List<Sweet> sweetStock = new ArrayList<>();

    private SweetSupplier sweetSupplier;

    @Autowired
    public Cafe(SweetSupplier sweetSupplier) {
        this.sweetSupplier = sweetSupplier;
    }

    public void restockSweets(){
        sweetStock.addAll(sweetSupplier.getChocolateBars(15));
        sweetStock.addAll(sweetSupplier.getCakes(20));
    }
}
@Component
public class SweetSupplier {

    public List<Sweet> getChocolateBars(int number) {
        //some code
    }

    public List<Sweet> getCakes(int number) {
        //some code
    }
}
Kotlin
@Component
class Cafe( @Autowired val sweetSupplier: SweetSupplier) {
    var sweetStock: MutableList<Sweet> = ArrayList()

    fun restockSweets() {
        sweetStock.addAll(sweetSupplier.getChocolateBars(15))
        sweetStock.addAll(sweetSupplier.getCakes(20))
    }
}
@Component
class SweetSupplier {
    fun getChocolateBars(number: Int): List<Sweet> {
        //some code
    }

    fun getCakes(number: Int): List<Sweet> {
        //some code
    }
}

You need to test how these two classes work together.

Check all steps that are mandatory to test the restockSweets method of the Cafe class.

Select one or more options from the list
___

Create a free account to access the full topic