exceptionfactory commented on code in PR #11562:
URL: https://github.com/apache/nifi/pull/11562#discussion_r3847662632
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/StandardNiFiServiceFacadeTest.java:
##########
@@ -2429,6 +2436,119 @@ public void
testGetConnectorParameterContextReturnsNullWhenNoBoundContext() {
verifyNoInteractions(dtoFactory);
}
+ @Test
+ public void
testGetComponentsAffectedByParameterContextUpdateTwicePreservesInheritedProviderProvenance()
{
+ final String targetContextId = "target-context";
+ final String inheritedContextId = "inherited-context";
+ final String inheritedParameterName = "inherited-provider-param";
+ final String processorId = "processor-id";
+
+ final ParameterDescriptor inheritedDescriptor = new
ParameterDescriptor.Builder().name(inheritedParameterName).build();
+ final Parameter inheritedParameter = new Parameter.Builder()
+ .descriptor(inheritedDescriptor)
+ .value("provider-value")
Review Comment:
It looks like like `provider-value` should be declared as a variable and
reused instead of stated multiple times across different lines in this method
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/ParameterContextResourceTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.api;
+
+import org.apache.nifi.authorization.AuthorizableLookup;
+import org.apache.nifi.authorization.AuthorizeAccess;
+import org.apache.nifi.authorization.Authorizer;
+import org.apache.nifi.authorization.RequestAction;
+import org.apache.nifi.authorization.user.NiFiUser;
+import org.apache.nifi.authorization.user.NiFiUserDetails;
+import org.apache.nifi.authorization.user.StandardNiFiUser;
+import org.apache.nifi.parameter.ParameterContext;
+import org.apache.nifi.web.NiFiServiceFacade;
+import org.apache.nifi.web.api.dto.AffectedComponentDTO;
+import org.apache.nifi.web.api.dto.DtoFactory;
+import org.apache.nifi.web.api.dto.EntityFactory;
+import org.apache.nifi.web.api.dto.ParameterContextDTO;
+import org.apache.nifi.web.api.dto.RevisionDTO;
+import org.apache.nifi.web.api.entity.AffectedComponentEntity;
+import org.apache.nifi.web.api.entity.ParameterContextEntity;
+import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity;
+import org.apache.nifi.web.security.token.NiFiAuthenticationToken;
+import org.apache.nifi.web.util.ParameterUpdateManager;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.same;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+public class ParameterContextResourceTest {
Review Comment:
The `public` modifier can be removed
##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java:
##########
@@ -1810,14 +1812,31 @@ private void setEffectiveParameterUpdates(final
ParameterContextDTO parameterCon
parameterEntity =
dtoFactory.createParameterEntity(parameterContext, parameter, revisionManager,
parameterContextDAO);
}
- // Parameter is inherited if either this is the removal of a
parameter not directly in this context, or it's parameter not specified
directly in the DTO
- final boolean isInherited = (parameter == null &&
!parameterContext.getParameters().containsKey(new
ParameterDescriptor.Builder().name(parameterName).build()))
- || (parameter != null &&
!parameterEntities.containsKey(parameterName));
- parameterEntity.getParameter().setInherited(isInherited);
+ if (parameter == null) {
+ parameterEntity.getParameter().setInherited(!locallyOwned);
+ } else {
+ final ParameterContext containingParameterContext =
getContainingParameterContext(parameterContext, parameter, locallyOwned);
+ final boolean isInherited = !locallyOwned &&
!Objects.equals(parameterContext.getIdentifier(),
containingParameterContext.getIdentifier());
Review Comment:
If a user has configured an alias using `#{Parameter Name}` does this
approach handle it? It seems like the inheritance check would end up overriding
that reference, using the resolved value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]