|
| 1 | +/* |
| 2 | + * Copyright 2012-2024 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.test.mock.mockito; |
| 18 | + |
| 19 | +import java.util.UUID; |
| 20 | + |
| 21 | +import org.junit.jupiter.api.Disabled; |
| 22 | +import org.junit.jupiter.api.MethodOrderer; |
| 23 | +import org.junit.jupiter.api.Nested; |
| 24 | +import org.junit.jupiter.api.Order; |
| 25 | +import org.junit.jupiter.api.Test; |
| 26 | +import org.junit.jupiter.api.TestMethodOrder; |
| 27 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 28 | +import org.mockito.Mock; |
| 29 | +import org.mockito.MockedStatic; |
| 30 | + |
| 31 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 32 | + |
| 33 | +import static org.assertj.core.api.Assertions.assertThat; |
| 34 | + |
| 35 | +/** |
| 36 | + * Integration tests for {@link MockitoTestExecutionListener}. |
| 37 | + * |
| 38 | + * @author Moritz Halbritter |
| 39 | + */ |
| 40 | +@ExtendWith(SpringExtension.class) |
| 41 | +class MockitoTestExecutionListenerIntegrationTests { |
| 42 | + |
| 43 | + @Nested |
| 44 | + @TestMethodOrder(MethodOrderer.OrderAnnotation.class) |
| 45 | + class DisabledTests { |
| 46 | + |
| 47 | + private static final UUID uuid = UUID.randomUUID(); |
| 48 | + |
| 49 | + @Mock |
| 50 | + private MockedStatic<UUID> mockedStatic; |
| 51 | + |
| 52 | + @Test |
| 53 | + @Order(1) |
| 54 | + @Disabled |
| 55 | + void shouldReturnConstantValueDisabled() { |
| 56 | + this.mockedStatic.when(UUID::randomUUID).thenReturn(uuid); |
| 57 | + UUID result = UUID.randomUUID(); |
| 58 | + assertThat(result).isEqualTo(uuid); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + @Order(2) |
| 63 | + void shouldReturnConstantValue() { |
| 64 | + this.mockedStatic.when(UUID::randomUUID).thenReturn(uuid); |
| 65 | + UUID result = UUID.randomUUID(); |
| 66 | + assertThat(result).isEqualTo(uuid); |
| 67 | + } |
| 68 | + |
| 69 | + } |
| 70 | + |
| 71 | +} |
0 commit comments