Skip to content

Commit

Permalink
♻️ integrations refactor deprecated catchThrowableOfType (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir authored Dec 9, 2024
1 parent a2e2b7d commit e3f5773
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void readContentMetadata() throws DmsException {
void readMetadataThrowsDmsException() throws DmsException {
when(this.readMetadataOutPort.readMetadata(any(), any())).thenReturn(new Metadata("name", "Ausgang", "url"));

final DmsException dmsException = catchThrowableOfType(() -> readMetadataUseCase.readMetadata(ObjectType.Sachakte, COO, USER), DmsException.class);
final DmsException dmsException = catchThrowableOfType(DmsException.class, () -> readMetadataUseCase.readMetadata(ObjectType.Sachakte, COO, USER));

final String expectedMessage = String.format(
"WRONG_INPUT_OBJECT_CLASS: The input object with the COO address %s is invalid because it is of the object class %s and this does not match the expected object class(es) %s.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void sendMailWithTemplate() throws MessagingException, TemplateException, IOExce
@Test
void sendMailWithTemplateThrowsIOException() throws TemplateException, IOException {
doThrow(new IOException("IO Exception")).when(mailOutPort).getBodyFromTemplate(anyString(), anyMap());
final TemplateError error = catchThrowableOfType(() -> sendMailInPort.sendMailWithTemplate(templateMail), TemplateError.class);
final TemplateError error = catchThrowableOfType(TemplateError.class, () -> sendMailInPort.sendMailWithTemplate(templateMail));

final String expectedMessage = "The template " + templateMail.getTemplate() + " could not be loaded";
final String actualMessage = error.getMessage();
Expand All @@ -131,7 +131,7 @@ void sendMailWithTemplateThrowsTemplateException() throws TemplateException, IOE
final TemplateException templateException = mock(TemplateException.class);
when(templateException.getMessage()).thenReturn("Template Exception Message");
doThrow(templateException).when(mailOutPort).getBodyFromTemplate(anyString(), anyMap());
final TemplateError error = catchThrowableOfType(() -> sendMailInPort.sendMailWithTemplate(templateMail), TemplateError.class);
final TemplateError error = catchThrowableOfType(TemplateError.class, () -> sendMailInPort.sendMailWithTemplate(templateMail));

final String expectedMessage = "Template Exception Message";
final String actualMessage = error.getMessage();
Expand Down

0 comments on commit e3f5773

Please sign in to comment.