You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/02/06 15:50:22 UTC

[GitHub] [nifi] ottobackwards opened a new pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

ottobackwards opened a new pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043
 
 
   
   
   #### Description of PR
   
   Adds a mock validator so that tests can verify that validators are called, used for example with the ListValidator to be sure the item level validator is called.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [x] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically `master`)?
   
   - [x] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [x] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [x] Have you written or updated unit tests to verify your changes?
   - [-] Have you verified that the full build is successful on both JDK 8 and JDK 11?
   - [- ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [-] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [-] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [-] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [-] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377658720
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   I'm OK with it in this instance, since one is specifically for the provided StandardValidators and the other is for custom validators. Pretty sure we've done things like this before for the same reason (search for `MockDBCPService` in the codebase 😄 )

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377803491
 
 

 ##########
 File path: nifi-mock/src/test/java/org/apache/nifi/util/validator/InstrumentedValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
 
 Review comment:
   ok, working on it

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377231174
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   Do you think this would be useful in general for unit tests? If so perhaps it should be in the `nifi-mock` module rather than the test sources for `nifi-utils`? I'm fine either way, but this looks like it could be useful in other places, especially things like unit tests for scripted components. I realize nifi-mock brings in nifi-utils, but I don't think it will bring in test artifacts, so wanted to know your thoughts for the best location.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] asfgit closed pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377235821
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   I *think* the ideal place would be mocks.  The mocks brings in utils and api and utils uses mocks to test part gave me pause

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377649521
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   @mattyb149, I tried to move it, and add a test stop dependency to nifi-mock to nifi-utils, I get cyclic dependency errors and cannot build

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] mattyb149 commented on issue #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on issue #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#issuecomment-585289520
 
 
   +1 LGTM (Travis failures are unrelated), ran contrib-check, everything looks good. Thanks for the improvement! Merging to master

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377236590
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   I could try it in mocks and "see" what happens, then rebase/force push if it works, how does that sound?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377656585
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   As long as everyone is OK with the DRYness ;)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377658345
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   Also, breaking the current naming scheme
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377655229
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   Makes sense, since the test is in nifi-utils (along with the unit-under-test). Still it sounds useful in general, what about a StandardValidators-specific one in nifi-utils (the way you have it now), perhaps having `StandardValidator` in the name (I was thinking about something besides `Test` that indicates you're instrumenting a real one, perhaps `InstrumentedStandardValidator` for the one in nifi-utils, and then have another one in nifi-mock called `InstrumentedValidator`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377231174
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   Do you think this would be useful in general for unit tests? If so perhaps it should be in the `nifi-mock` module rather than the test sources for `nifi-utils`? I'm fine either way, but this looks like it could be useful in other places, especially things like unit tests for scripted components.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
mattyb149 commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377783726
 
 

 ##########
 File path: nifi-mock/src/test/java/org/apache/nifi/util/validator/InstrumentedValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
 
 Review comment:
   This one should go in the main sources so it's available to other modules to test their validators, otherwise it is only available to test classes in this module

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi] ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…

Posted by GitBox <gi...@apache.org>.
ottobackwards commented on a change in pull request #4043: NIFI-7109 Unit tests should be able to determine if item validator wa…
URL: https://github.com/apache/nifi/pull/4043#discussion_r377231804
 
 

 ##########
 File path: nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestMockValidator.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * 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.util.validator;
+
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+/**
+ * TestMockValidator wraps a {@class Validator} and provides statistics on it's interactions.
+ * Because many of the {@class Validator} instances returned from {@class StandardValidator }
+ * are not mockable with with mockito, this is required to know, when running a test, if a
+ * {@class Validator} was in fact called, for example.
+ */
+public class TestMockValidator implements Validator {
 
 Review comment:
   That was my first thought @mattyb149 , but I thought it would introduce dependency issues.  Maybe I was wrong?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services