[mielecloud] Less strict e-mail validation (#10928)

* [mielecloud] Less strict e-mail validation

Signed-off-by: Björn Lange <bjoern.lange@tu-dortmund.de>

* Some more e-mail validation test cases

Signed-off-by: Björn Lange <bjoern.lange@tu-dortmund.de>

Co-authored-by: Björn Lange <bjoern.lange@tu-dortmund.de>
This commit is contained in:
Björn Lange
2021-07-17 23:18:12 +02:00
committed by GitHub
parent bd1d8f4980
commit dbefba3fdd
4 changed files with 56 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.mielecloud.internal.util;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
/**
* @author Björn Lange - Initial Contribution
*/
@NonNullByDefault
public class EmailValidatorTest {
@ParameterizedTest
@ValueSource(strings = { "example@openhab.org", "itsme@test24.com", "my-account@t-online.de", "Some@dDRESs.edu",
"min@Length.com" })
void validEmailAddress(String emailAddress) {
// when:
var valid = EmailValidator.isValid(emailAddress);
// then:
assertTrue(valid);
}
@ParameterizedTest
@ValueSource(strings = { "examp!e@###.org", "to@o.short.com" })
void invalidEmailAddress(String emailAddress) {
// when:
var valid = EmailValidator.isValid(emailAddress);
// then:
assertFalse(valid);
}
}