Hello everyone. I have a question about testing customException... I have a class:

public class CustomException extends RuntimeException {
    private final String zhliga;
    public CustomException (String warningMessage, String zhliga) {
        super (warningMessage);
        this.zhliga= zhliga;
    public String getZhliga () {
        return zhliga;

CustomExceptionI am throwing out in a method that saves an object to an array when going out of bounds of the array.

public void save (Object obj) {
    int index= getIndex (obj.getZhliga ());
    if (index >
= 0) {
        throw new ExistStorageException (obj.getZhliga ());
    } else if (size >
       throw new CustomException ("Array overflow", obj.getZhliga ());
    } else {
        addObjectToArray (obj, index);
        size ++;

So the question is how to test inJunit5myCustomExceptionby a separate method? Thank you for paying attention to my question.