vaadin tutorial contactformtest with confirm dialog: test fails!

i’m pretty new to vaadin. I’ve followed and successfully completed the tutorial on I have tried now to add a confirm dialog in the contactForm class, that should pop up when the button ‘save’ is clicked. These are basically the lines i changed/added:
private void validateAndSave() {
if(binder.isValid()) {
ConfirmAndSave(); // CHANGED

//ADDED: New function with confirm dialog
private void ConfirmAndSave(){
ConfirmDialog dialog = new ConfirmDialog();
dialog.setHeader(“Save contact?”);
dialog.setText(“Are you sure you want to save this contact?”);
dialog.setConfirmButtonTheme(“error primary”);
dialog.addConfirmListener(event → fireEvent(new ContactForm.SaveEvent(this, binder.getBean())));;
It works so far, but now the automatic test fails with the error: java.lang.IllegalStateException: UI instance is not available. It means that you are calling this method out of a normal workflow where it’s always implicitly set. That may happen if you call the method from the custom thread without ‘UI::access’ or from tests without proper initialization.
The problem seems to be this line in contactFormTest class:;
How can i change this test to work with the confirmdialog?
I’d really appreciate your help, thank you