Skip to content

Commit

Permalink
Fix some test naming things
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-dejongh committed Oct 22, 2024
1 parent f0c139f commit 5a63c5a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package be.sddevelopment.validation.core;

import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing;
import org.assertj.core.api.WithAssertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.commons.util.StringUtils;
Expand All @@ -21,10 +23,11 @@

@DisplayName("Constrainables")
@ExtendWith({MockitoExtension.class})
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class)
class ConstrainedTest implements WithAssertions {

@Test
void givenValidData_whenApplyingRule_itsEvaluationIsRemembered() {
void ruleEvaluationResultIsRetained_givenValidData_whenApplyingRule() {
var contentToCheck = "This is a non empty String";
var rule = new Constraint<>(Predicate.not(String::isBlank), "mustn't be blank");
assertThat(rule.rule().test(contentToCheck)).isTrue();
Expand All @@ -38,7 +41,7 @@ void givenValidData_whenApplyingRule_itsEvaluationIsRemembered() {
}

@Test
void givenInvalidData_whenApplyingRule_itIsEvaluatedAsInvalid() {
void ruleEvaluationResultIsInvalid_givenInvalidData_whenApplyingRule() {
var empty = "";
var rule = new Constraint<>(Predicate.not(String::isBlank), "mustn't be blank");
assertThat(rule.rule().test(empty)).isFalse();
Expand Down Expand Up @@ -73,7 +76,7 @@ void feedback_hasNoEffect_givenValidSourceData() {
}

@Test
void ifValid_givenTheDateIsValid_CallsTheProvidedConsumer() {
void callsAProvidedConsumer_givenTheDataIsValid() {
var checked = constrain("I am a real String").adheresTo(Constraints.isNotEmpty());
var consumer = new MessageStore();
assertThat(checked).is(valid());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package be.sddevelopment.validation.core;

import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing;
import be.sddevelopment.validation.CheckedTestUtils;
import org.assertj.core.api.WithAssertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.StringUtils;

Expand All @@ -14,6 +16,7 @@
import static be.sddevelopment.validation.core.Reason.passed;

@DisplayName("Constraints / Rules")
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class)
class ConstraintTest implements WithAssertions {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
package be.sddevelopment.validation.core;

import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing;
import org.assertj.core.api.WithAssertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.Test;

import static be.sddevelopment.validation.core.Checks.haveNonNullField;

@DisplayName("Constraints utility class")
class ContrainsTest implements WithAssertions {
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class)
class ContraintsTest implements WithAssertions {

@Test
void givenAnObjectWithANullField_havingNonNullFieldPredicate_fails() {
void validationFails_givenAnObjectWithANullField_andUsingNonNullFieldPredicate() {
var toValidate = new DataObject(null);
var rule = haveNonNullField(DataObject::content);

assertThat(rule.test(toValidate)).isFalse();
}

@Test
void givenAnObjectWithNoNullField_havingNonNullFieldPredicate_succeeds() {
void validationSucceeds_givenAnObjectWithNoNullField_andUsingNonNullFieldPredicate() {
var toValidate = new DataObject("Some content");
var rule = haveNonNullField(DataObject::content);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package be.sddevelopment.validation.core;

import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing;
import org.assertj.core.api.WithAssertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.Test;

import static be.sddevelopment.validation.core.Reason.failed;
import static be.sddevelopment.validation.core.Reason.passed;

@DisplayName("InvalidObject Exceptions")
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class)
class InvalidObjectExceptionTest implements WithAssertions {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package be.sddevelopment.validation.specs.usage;

import be.sddevelopment.commons.testing.naming.ReplaceUnderscoredCamelCasing;
import be.sddevelopment.validation.core.*;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -27,6 +28,7 @@
import static org.apache.commons.lang3.StringUtils.containsIgnoreCase;

@DisplayName("Basic Usage")
@DisplayNameGeneration(ReplaceUnderscoredCamelCasing.class)
class BasicUsageTest implements WithAssertions {

@Nested
Expand Down Expand Up @@ -85,7 +87,7 @@ private record EmailContact(UUID userIdentifier, String email, String name, Stri
}

@Nested
@DisplayName("Constrained objects should allow for fluent usage")
@DisplayName("Constrained objects allow for fluent usage")
class ConstrainedUsage {
private static final ModularRuleset<DateBasedDummyObject> DATE_REQUIREMENTS = aValid(ConstrainedUsage.DateBasedDummyObject.class)
.must(Objects::nonNull, "not be null")
Expand Down

0 comments on commit 5a63c5a

Please sign in to comment.