This is my Flaw class
enum Flaw {
NOUPPER( 'U', "No UPPER case letter" ),
NOLOWER( 'l', "No lower case letter" ),
NODIGIT( '8', "No digit" ),
NOSPECIAL( '#', "No special character" ),
TOO_SHORT( 's', "Too short" );
final char encoding;
final String description;
Flaw( char encoding, String description ) {
this.encoding = encoding;
this.description = description;
}
char getEncoding() {
return encoding;
}
String getDescription() {
return description;
}
static Flaw encodingToFlaw( char encoding ) {
for ( validator.Flaw flaw : values() ) {
if ( flaw.getEncoding() == encoding ) {
return flaw;
}
}
return null;
}
/**
* Collect the encoded flaws into an initially empty set.
* @param encoding the flaws
* @return the set of flaws matching the encoding.
*/
static EnumSet<Flaw> stringToFlawSet( String encoding ) {
return encoding.chars()
.mapToObj( c -> Flaw.encodingToFlaw( (char) c ) )
.filter( f -> f != null )
.collect( toCollection( () -> noneOf( Flaw.class ) ) );
}
And this is my Test class, I need to work in a TDM style and I cannot find the right approach on my assignments. I hope you can help me to understand what kind of approach I should take and also to understand how to test correctly
@ParameterizedTest
@CsvSource({
"'password', 'U|8|#|s|l'",
// "'I AM A UPPERCASE PASSWORD', 'uppercase'",
// "'I am a good password with 1 digit', 'digit'",
// "'I am a perfect Password #69', 'special'"
})
void invalidPassword(String password, String miss){
String [] missArray = miss.split("//|");
EnumSet<Flaw> flaws = EnumSet.allOf( Flaw.class );
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(password)
.hasSizeGreaterThan(9);
});
Aucun commentaire:
Enregistrer un commentaire