BAEL-5760: Change test names to BDD format (#12856)

Co-authored-by: Loredana Crusoveanu <lore.crusoveanu@gmail.com>
This commit is contained in:
Eugene Kovko
2022-10-13 21:47:24 +02:00
committed by GitHub
parent fe09cfb802
commit 88c31bab42
21 changed files with 453 additions and 0 deletions
@@ -0,0 +1,19 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
class CollectionUnitTest {
@Test
void whenGettingFictionaCharacters_thenResultNotEmptyAndOfCorrectSize() {
assertAll(
() -> assertThat(Collection.getFictionalCharacters()).isNotEmpty(),
() -> assertThat(Collection.getFictionalCharacters()).size().isGreaterThanOrEqualTo(Collection.MIN),
() -> assertThat(Collection.getFictionalCharacters()).size().isLessThanOrEqualTo(Collection.MAX)
);
}
}
@@ -0,0 +1,27 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
class CsvUnitTest {
@Test
void whenGettingFirstExpression_thenResultNotEmptyAndOfCorrectSizeAndFormat() {
assertAll(
() -> assertThat(Csv.getFirstExpression()).isNotBlank(),
() -> assertThat(Csv.getFirstExpression().split("\n")).hasSize(5),
() -> assertThat(Csv.getFirstExpression().split("\n")[0]).isEqualTo("\"name_column\",\"last_name_column\"")
);
}
@Test
void whenGettingSecondExpression_thenResultNotEmptyAndOfCorrectSizeAndFormat() {
assertAll(
() -> assertThat(Csv.getFirstExpression()).isNotBlank(),
() -> assertThat(Csv.getFirstExpression().split("\n")).hasSize(5),
() -> assertThat(Csv.getFirstExpression().split("\n")[0]).isEqualTo("\"name_column\",\"last_name_column\"")
);
}
}
@@ -0,0 +1,26 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
class ExamplifyUnitTest {
@Test
void whenGettingNumberExpression_thenResultNotEmptyAndMathesRegex() {
assertAll(
() -> assertThat(Examplify.getNumberExpression()).isNotBlank(),
() -> assertThat(Examplify.getNumberExpression()).matches("\\d{3}-\\d{3}-\\d{3}")
);
}
@Test
void whenGettingExpression_thenResultNotEmptyAndMathesRegex() {
assertAll(
() -> assertThat(Examplify.getExpression()).isNotBlank(),
() -> assertThat(Examplify.getExpression())
.matches("[A-Z][a-z]{2} [a-z]{2} [a-z]{3} [A-Z][a-z]{2}")
);
}
}
@@ -0,0 +1,21 @@
package com.baeldung.datafaker;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.junit.jupiter.api.Assertions.*;
class JsonUnitTest {
private static final ObjectMapper objectMapper = new ObjectMapper();
@Test
void whenGettingJsonExpression_thenResultIsValidJson() {
assertAll(
() -> assertThatNoException().isThrownBy(() -> objectMapper.readTree(Json.getExpression())),
() -> assertThat(Json.getExpression()).isNotBlank()
);
}
}
@@ -0,0 +1,18 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class MethodInvocationUnitTest {
@Test
void whenGettingNameFromExpression_thenResultNotEmpty() {
assertThat(MethodInvocation.getNameFromMethod()).isNotBlank();
}
@Test
void whenGettingNameFromMethod_thenResultNotEmpty() {
assertThat(MethodInvocation.getNameFromExpression()).isNotBlank();
}
}
@@ -0,0 +1,23 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import java.time.Duration;
import static org.assertj.core.api.Assertions.assertThat;
class MethodInvocationWithParamsUnitTest {
@Test
void whenGettingDurationFromExpression_thenResultNotEmpty() {
assertThat(MethodInvocationWithParams.getDurationFromExpression()).isNotBlank();
}
@Test
void whenGettingDurationFromMethod_thenResultNotNullAndInBoundaries() {
assertThat(MethodInvocationWithParams.getDurationFromMethod())
.isNotNull()
.isBetween(Duration.ofSeconds(MethodInvocationWithParams.MIN),
Duration.ofSeconds(MethodInvocationWithParams.MAX));
}
}
@@ -0,0 +1,18 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
class MixedCollectionUnitTest {
@Test
void whenGettingMixedCollection_thenResultNotEmptyAndOfCorrectSize() {
assertAll(
() -> assertThat(MixedCollection.getMixedCollection()).isNotEmpty(),
() -> assertThat(MixedCollection.getMixedCollection()).size().isGreaterThanOrEqualTo(MixedCollection.MIN),
() -> assertThat(MixedCollection.getMixedCollection()).size().isLessThanOrEqualTo(MixedCollection.MAX)
);
}
}
@@ -0,0 +1,25 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class OptionUnitTest {
@Test
void whenGettingThirdExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Option.getThirdExpression()).isNotBlank()
.matches("(Hi|Hello|Hey)");
}
@Test
void whenGettingSecondExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Option.getSecondExpression()).isNotBlank()
.matches("(1|2|3|4|\\*)");
}
@Test
void whenGettingFirstExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Option.getFirstExpression()).isNotBlank()
.matches("(Hi|Hello|Hey)");
}
}
@@ -0,0 +1,20 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class RegexifyUnitTest {
@Test
void whenGettingMethidExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Regexify.getMethodExpression()).isNotBlank()
.matches("[A-D]{4,10}");
}
@Test
void whenGettingExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Regexify.getExpression()).isNotBlank()
.matches("(hello|bye|hey)");
}
}
@@ -0,0 +1,19 @@
package com.baeldung.datafaker;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class TemplatifyUnitTest {
@Test
void whenGettingPlaceholderExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Templatify.getExpressionWithPlaceholder()).isNotBlank()
.matches(".ight");
}
@Test
void whenGettingExpression_thenResultNotBlankAndMatchesRegex() {
assertThat(Templatify.getExpression()).isNotBlank()
.matches(".es.");
}
}