|
| 1 | +package com.github.nagyesta.abortmission.core.extractor.impl; |
| 2 | + |
| 3 | +import com.github.nagyesta.abortmission.core.annotation.LaunchSequence; |
| 4 | +import com.github.nagyesta.abortmission.core.outline.MissionOutline; |
| 5 | +import org.junit.jupiter.api.Assertions; |
| 6 | +import org.junit.jupiter.api.DisplayName; |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | + |
| 9 | +import java.util.Collections; |
| 10 | +import java.util.List; |
| 11 | +import java.util.Optional; |
| 12 | +import java.util.Set; |
| 13 | + |
| 14 | +@DisplayName("AnnotationSimpleNameDependencyExtractorTest") |
| 15 | +@LaunchSequence(MissionOutline.class) |
| 16 | +class AnnotationSimpleNameDependencyExtractorTest { |
| 17 | + |
| 18 | + @Test |
| 19 | + void testExtractValuesFromAnnotationShouldReturnSetOfAnnotationNamesWhenCalledWithAnnotatedClass() { |
| 20 | + //given |
| 21 | + final AnnotationSimpleNameDependencyExtractor underTest = new AnnotationSimpleNameDependencyExtractor(); |
| 22 | + |
| 23 | + //when |
| 24 | + final Optional<Set<String>> actual = underTest.apply(this.getClass()); |
| 25 | + |
| 26 | + //then |
| 27 | + Assertions.assertIterableEquals(List.of("DisplayName", "LaunchSequence"), actual.orElse(Collections.emptySet())); |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + void testExtractValuesFromAnnotationShouldReturnEmptyWhenCalledWithNotAnnotatedClass() { |
| 32 | + //given |
| 33 | + final AnnotationSimpleNameDependencyExtractor underTest = new AnnotationSimpleNameDependencyExtractor(); |
| 34 | + |
| 35 | + //when |
| 36 | + final Optional<Set<String>> actual = underTest.apply(NotAnnotated.class); |
| 37 | + |
| 38 | + //then |
| 39 | + Assertions.assertTrue(actual.isEmpty()); |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + void testExtractValuesFromAnnotationShouldReturnEmptyWhenCalledWithNonClassObject() { |
| 44 | + //given |
| 45 | + final AnnotationSimpleNameDependencyExtractor underTest = new AnnotationSimpleNameDependencyExtractor(); |
| 46 | + |
| 47 | + //when |
| 48 | + final Optional<Set<String>> actual = underTest.apply(this); |
| 49 | + |
| 50 | + //then |
| 51 | + Assertions.assertTrue(actual.isEmpty()); |
| 52 | + } |
| 53 | + |
| 54 | + private static class NotAnnotated { |
| 55 | + } |
| 56 | +} |
0 commit comments