From c8ccd522a5e55ce8eea17fad576af2cff528d21a Mon Sep 17 00:00:00 2001 From: Oleksandra Matviienko Date: Mon, 6 Mar 2023 13:59:09 +0100 Subject: [PATCH] junit5: BaseOAuth2ServiceTest annotation exceptions refactoring --- .../server/dao/service/BaseOAuth2ServiceTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/BaseOAuth2ServiceTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/BaseOAuth2ServiceTest.java index 42ea18bdec..73dd08d53c 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/service/BaseOAuth2ServiceTest.java +++ b/dao/src/test/java/org/thingsboard/server/dao/service/BaseOAuth2ServiceTest.java @@ -20,6 +20,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.jupiter.api.Assertions; import org.springframework.beans.factory.annotation.Autowired; import org.thingsboard.server.common.data.StringUtils; import org.thingsboard.server.common.data.oauth2.MapperType; @@ -61,7 +62,7 @@ public abstract class BaseOAuth2ServiceTest extends AbstractServiceTest { Assert.assertTrue(oAuth2Service.findOAuth2Info().getOauth2ParamsInfos().isEmpty()); } - @Test(expected = DataValidationException.class) + @Test public void testSaveHttpAndMixedDomainsTogether() { OAuth2Info oAuth2Info = new OAuth2Info(true, Lists.newArrayList( OAuth2ParamsInfo.builder() @@ -77,10 +78,12 @@ public abstract class BaseOAuth2ServiceTest extends AbstractServiceTest { )) .build() )); - oAuth2Service.saveOAuth2Info(oAuth2Info); + Assertions.assertThrows(DataValidationException.class, () -> { + oAuth2Service.saveOAuth2Info(oAuth2Info); + }); } - @Test(expected = DataValidationException.class) + @Test public void testSaveHttpsAndMixedDomainsTogether() { OAuth2Info oAuth2Info = new OAuth2Info(true, Lists.newArrayList( OAuth2ParamsInfo.builder() @@ -96,7 +99,9 @@ public abstract class BaseOAuth2ServiceTest extends AbstractServiceTest { )) .build() )); - oAuth2Service.saveOAuth2Info(oAuth2Info); + Assertions.assertThrows(DataValidationException.class, () -> { + oAuth2Service.saveOAuth2Info(oAuth2Info); + }); } @Test