mirror of https://github.com/apache/nifi.git
NIFI-13577 Corrected null handling in Parameter Value Mapper (#9107)
This commit is contained in:
parent
c31fb9d373
commit
11fdc44fb9
|
@ -48,7 +48,9 @@ public class StandardParameterValueMapper implements ParameterValueMapper {
|
||||||
final ParameterDescriptor descriptor = parameter.getDescriptor();
|
final ParameterDescriptor descriptor = parameter.getDescriptor();
|
||||||
final String mapped;
|
final String mapped;
|
||||||
|
|
||||||
if (parameter.isProvided()) {
|
if (value == null) {
|
||||||
|
mapped = null;
|
||||||
|
} else if (parameter.isProvided()) {
|
||||||
mapped = PROVIDED_MAPPING;
|
mapped = PROVIDED_MAPPING;
|
||||||
} else if (descriptor.isSensitive()) {
|
} else if (descriptor.isSensitive()) {
|
||||||
if (sensitiveValueEncryptor == null) {
|
if (sensitiveValueEncryptor == null) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class TestStandardParameterValueMapper {
|
class TestStandardParameterValueMapper {
|
||||||
|
@ -79,6 +80,15 @@ class TestStandardParameterValueMapper {
|
||||||
assertNotEquals(StandardParameterValueMapper.PROVIDED_MAPPING, mapped);
|
assertNotEquals(StandardParameterValueMapper.PROVIDED_MAPPING, mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testGetMappedSensitiveNotProvidedNullValue() {
|
||||||
|
final Parameter parameter = getParameter(true, false);
|
||||||
|
|
||||||
|
final String mapped = mapper.getMapped(parameter, null);
|
||||||
|
|
||||||
|
assertNull(mapped);
|
||||||
|
}
|
||||||
|
|
||||||
private Parameter getParameter(final boolean sensitive, final boolean provided) {
|
private Parameter getParameter(final boolean sensitive, final boolean provided) {
|
||||||
final ParameterDescriptor descriptor = new ParameterDescriptor.Builder().name(NAME).sensitive(sensitive).build();
|
final ParameterDescriptor descriptor = new ParameterDescriptor.Builder().name(NAME).sensitive(sensitive).build();
|
||||||
return new Parameter(descriptor, VALUE, null, provided);
|
return new Parameter(descriptor, VALUE, null, provided);
|
||||||
|
|
Loading…
Reference in New Issue