concept normal behavior in category security

appears as: normal behavior, normal behavior
Secure by Design

This is an excerpt from Manning's book Secure by Design.

At first, it can be tempting to represent an email address as a String because of the generous definition in RFC 5322. But the requirements defined by the domain rules suggests that a better choice would be to represent it as a domain primitive, EmailAddress. One way to ensure it complies with the domain rules is to drive the design using unit tests, so let’s start by testing normal behavior.

Listing 8.1 Test capturing the normal behavior of EmailAddress
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
 
class EmailAddressTest {
  @TestFactory
  Stream<DynamicTest> should_be_a_valid_address() {
     return Stream.of(    #1  
           "jane@hospital.com",    #2  
           "jane01@hospital.com",    #2  
           "jane.doe@hospital.com")    #2  
           .map(input ->
              dynamicTest("Accepted: " + input,    #3  
                () -> assertDoesNotThrow(  #4  
                  () -> new EmailAddress(input)))); 
  }
}

#1   Creates a stream of input values
#2   Input values that clearly satisfy the domain rules
#3   Creates a dynamic test case at runtime
#4   Asserts that the input doesn’t throw an exception when an EmailAddress object is created