Description
I am not sure whether this is the expected behavior, I do not believe it is.
new BootNotificationRequest().setChargeBoxSerialNumber(null);
throws a NullPointerException
due to .length()
in
if (!ModelUtil.validate(chargeBoxSerialNumber, STRING_25_CHAR_MAX_LENGTH)) {
throw new PropertyConstraintException(
chargeBoxSerialNumber.length(), validationErrorMessage(STRING_25_CHAR_MAX_LENGTH));
}
being called on a null
String
.
Note that chargeBoxSerialNumber
is optional in BootNotificationRequest
.
Here's a test for reproduction:
package eu.chargetime.ocpp.model.core.test;
import eu.chargetime.ocpp.model.core.BootNotificationRequest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
public class BootNotificationRequestTest {
@Rule public ExpectedException thrownException = ExpectedException.none();
private BootNotificationRequest request;
@Before
public void setup() {
request = new BootNotificationRequest();
}
@Test()
public void validate_setChargeBoxSerialNumber_onNull_doesNotThrowNPE() {
request.setChargeBoxSerialNumber(null);
}
}
Metadata
Metadata
Assignees
Labels
No labels