diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java index 73d8aad810..0c437affd8 100644 --- a/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/classes/VehicleUnitTest.java @@ -18,19 +18,19 @@ public class VehicleUnitTest { } @Test - public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() { + public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() throws ClassNotFoundException { Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(car.getClass().getSuperclass().isSealed()).isEqualTo(true); Assertions.assertThat(car.getClass().getSuperclass().getPermittedSubclasses()) - .contains(ClassDesc.of(car.getClass().getCanonicalName())); + .contains(Class.forName(car.getClass().getCanonicalName())); } @Test - public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() { + public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() throws ClassNotFoundException { Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(truck.getClass().getSuperclass().isSealed()).isEqualTo(true); Assertions.assertThat(truck.getClass().getSuperclass().getPermittedSubclasses()) - .contains(ClassDesc.of(truck.getClass().getCanonicalName())); + .contains(Class.forName(truck.getClass().getCanonicalName())); } @Test diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java index ac8a8c953c..8dd150b5e7 100644 --- a/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java +++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/sealed/records/VehicleUnitTest.java @@ -18,19 +18,19 @@ public class VehicleUnitTest { } @Test - public void givenCar_whenUsingReflectionAPI_thenInterfaceIsSealed() { + public void givenCar_whenUsingReflectionAPI_thenInterfaceIsSealed() throws ClassNotFoundException { Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(car.getClass().getInterfaces()[0].isSealed()).isEqualTo(true); - Assertions.assertThat(car.getClass().getInterfaces()[0].permittedSubclasses()) - .contains(ClassDesc.of(car.getClass().getCanonicalName())); + Assertions.assertThat(car.getClass().getInterfaces()[0].getPermittedSubclasses()) + .contains(Class.forName(car.getClass().getCanonicalName())); } @Test - public void givenTruck_whenUsingReflectionAPI_thenInterfaceIsSealed() { + public void givenTruck_whenUsingReflectionAPI_thenInterfaceIsSealed() throws ClassNotFoundException { Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(truck.getClass().getInterfaces()[0].isSealed()).isEqualTo(true); - Assertions.assertThat(truck.getClass().getInterfaces()[0].permittedSubclasses()) - .contains(ClassDesc.of(truck.getClass().getCanonicalName())); + Assertions.assertThat(truck.getClass().getInterfaces()[0].getPermittedSubclasses()) + .contains(Class.forName(truck.getClass().getCanonicalName())); } @Test