Merge pull request #15231 from harry9656/JAVA-27338

JAVA-27338: Fix VehicleUnitTest
This commit is contained in:
Kasra Madadipouya 2023-11-17 19:46:57 +01:00 committed by GitHub
commit 4e24430ad2
2 changed files with 10 additions and 10 deletions

View File

@ -18,19 +18,19 @@ public class VehicleUnitTest {
} }
@Test @Test
public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() { public void givenCar_whenUsingReflectionAPI_thenSuperClassIsSealed() throws ClassNotFoundException {
Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false);
Assertions.assertThat(car.getClass().getSuperclass().isSealed()).isEqualTo(true); Assertions.assertThat(car.getClass().getSuperclass().isSealed()).isEqualTo(true);
Assertions.assertThat(car.getClass().getSuperclass().getPermittedSubclasses()) Assertions.assertThat(car.getClass().getSuperclass().getPermittedSubclasses())
.contains(ClassDesc.of(car.getClass().getCanonicalName())); .contains(Class.forName(car.getClass().getCanonicalName()));
} }
@Test @Test
public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() { public void givenTruck_whenUsingReflectionAPI_thenSuperClassIsSealed() throws ClassNotFoundException {
Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false);
Assertions.assertThat(truck.getClass().getSuperclass().isSealed()).isEqualTo(true); Assertions.assertThat(truck.getClass().getSuperclass().isSealed()).isEqualTo(true);
Assertions.assertThat(truck.getClass().getSuperclass().getPermittedSubclasses()) Assertions.assertThat(truck.getClass().getSuperclass().getPermittedSubclasses())
.contains(ClassDesc.of(truck.getClass().getCanonicalName())); .contains(Class.forName(truck.getClass().getCanonicalName()));
} }
@Test @Test

View File

@ -18,19 +18,19 @@ public class VehicleUnitTest {
} }
@Test @Test
public void givenCar_whenUsingReflectionAPI_thenInterfaceIsSealed() { public void givenCar_whenUsingReflectionAPI_thenInterfaceIsSealed() throws ClassNotFoundException {
Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(car.getClass().isSealed()).isEqualTo(false);
Assertions.assertThat(car.getClass().getInterfaces()[0].isSealed()).isEqualTo(true); Assertions.assertThat(car.getClass().getInterfaces()[0].isSealed()).isEqualTo(true);
Assertions.assertThat(car.getClass().getInterfaces()[0].permittedSubclasses()) Assertions.assertThat(car.getClass().getInterfaces()[0].getPermittedSubclasses())
.contains(ClassDesc.of(car.getClass().getCanonicalName())); .contains(Class.forName(car.getClass().getCanonicalName()));
} }
@Test @Test
public void givenTruck_whenUsingReflectionAPI_thenInterfaceIsSealed() { public void givenTruck_whenUsingReflectionAPI_thenInterfaceIsSealed() throws ClassNotFoundException {
Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false); Assertions.assertThat(truck.getClass().isSealed()).isEqualTo(false);
Assertions.assertThat(truck.getClass().getInterfaces()[0].isSealed()).isEqualTo(true); Assertions.assertThat(truck.getClass().getInterfaces()[0].isSealed()).isEqualTo(true);
Assertions.assertThat(truck.getClass().getInterfaces()[0].permittedSubclasses()) Assertions.assertThat(truck.getClass().getInterfaces()[0].getPermittedSubclasses())
.contains(ClassDesc.of(truck.getClass().getCanonicalName())); .contains(Class.forName(truck.getClass().getCanonicalName()));
} }
@Test @Test