Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACS-5449 Bump mockito-core from 4.9.0 to 5.4.0 #2071

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7d016e9
ACS-5449 Init commit
Jul 14, 2023
7633c82
ACS-5449 Bump mockito-core from 4.9.0 to 5.4.0
Jul 14, 2023
94352ac
ACS-5449 Update RuleServiceImplUnitTest.class
Jul 14, 2023
1cc6e53
ACS-5449 Update RuleServiceImplUnitTest.class
Jul 14, 2023
48b15f9
ACS-5449 Update RuleServiceImplUnitTest.class
Jul 14, 2023
c55345a
ACS-5449 Update test-messaging-context.xml
Jul 14, 2023
f5f1290
ACS-5449 Update test-nodeLocatorServiceImpl-context.xml
Jul 14, 2023
4b9d37e
ACS-5449 Update test-nodeLocatorServiceImpl-context.xml
Jul 14, 2023
161be9e
Merge branch 'master' into fix/ACS-5449_investigate-bump-mockito-core…
Jul 17, 2023
dd18bc7
Update test-messaging-context.xml
Jul 17, 2023
0f6fbe2
ACS-5449 Update CamelComponentsTest
Jul 17, 2023
2bf8289
ACS-5449 Update CamelComponentsTest
Jul 17, 2023
b3a08b1
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
c1f789f
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
6967e55
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
441d8ed
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
b5efbdb
ACS-5449 Update CamelComponentsTest
Jul 17, 2023
09da690
ACS-5449 Update CamelComponentsTest and test-messaging-context.xml
Jul 17, 2023
90c08fd
ACS-5449 Update CamelComponentsTest
Jul 17, 2023
02bd3d9
ACS-5449 Update CamelComponentsTest and test-messaging-context.xml
Jul 17, 2023
db492c5
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
58e847f
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
91bb4d4
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
8216e86
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
3b06db7
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
8baf0cd
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
e35e74d
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
8935510
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
bb08dea
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
02fdbd2
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
43cc502
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
b06f093
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
ef3de6a
ACS-5449 Update test-messaging-context.xml
Jul 17, 2023
85408bf
ACS-5449 Update LockServicePoliciesImpl class inside LockServiceImplTest
Jul 18, 2023
0942cb2
Merge branch 'master' into fix/ACS-5449_investigate-bump-mockito-core…
Jul 24, 2023
c3ec2bb
ACS-5449 Update test-messaging-context.xml
Jul 24, 2023
515bd9d
ACS-5449 Update test-messaging.xml and CamelComponentsTest
Jul 25, 2023
22c4148
ACS-5449 Update test-messaging.xml and CamelComponentsTest
Jul 25, 2023
b55d599
ACS-5449 Revert CamelComponentsTest to untouched version
Jul 25, 2023
e847d43
ACS-5449 Delete unused imports in RuleServiceImplUnitTest
Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
<dependency.webscripts.version>8.45</dependency.webscripts.version>
<dependency.bouncycastle.version>1.70</dependency.bouncycastle.version>
<dependency.mockito-core.version>4.9.0</dependency.mockito-core.version>
<dependency.mockito-core.version>5.4.0</dependency.mockito-core.version>
<dependency.assertj.version>3.24.2</dependency.assertj.version>
<dependency.org-json.version>20230618</dependency.org-json.version>
<dependency.commons-dbcp.version>2.9.0</dependency.commons-dbcp.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2018 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -84,16 +84,16 @@
@Category({BaseSpringTestsCategory.class})
@Transactional
public class LockServiceImplTest extends BaseSpringTest
{
/**
* Services used in tests
*/
private NodeService nodeService;
private LockService lockService;
private MutableAuthenticationService authenticationService;
private CheckOutCheckInService cociService;

Check warning on line 94 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

Perhaps 'cociService' could be replaced by a local variable.

Fields whose scopes are limited to just single methods do not rely on the containing object to provide them to other methods. They may be better implemented as local variables within those methods. SingularField (Priority: 3, Ruleset: Design) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_design.html#singularfield

private PermissionService permissionService;

Check warning on line 96 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

Perhaps 'permissionService' could be replaced by a local variable.

Fields whose scopes are limited to just single methods do not rely on the containing object to provide them to other methods. They may be better implemented as local variables within those methods. SingularField (Priority: 3, Ruleset: Design) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_design.html#singularfield
private LockService securedLockService;
/**
* Data used in tests
Expand All @@ -114,7 +114,7 @@
private PolicyComponent policyComponent;


private class LockServicePoliciesImpl implements LockServicePolicies.BeforeLock,
public class LockServicePoliciesImpl implements LockServicePolicies.BeforeLock,
LockServicePolicies.BeforeUnlock
{
@Override
Expand All @@ -123,7 +123,7 @@
if (logger.isDebugEnabled())
{
logger.debug("Invoked beforeLock() for nodeRef: " + nodeRef +
lockType != null ? (" and lockType: " + lockType) : "");

Check warning on line 126 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

Useless parentheses.

Useless parentheses should be removed. UselessParentheses (Priority: 4, Ruleset: Code Style) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#uselessparentheses
}
}

Expand Down Expand Up @@ -157,7 +157,7 @@
authComponent.setSystemUserAsCurrentUser();

// Create the node properties
HashMap<QName, Serializable> nodeProperties = new HashMap<QName, Serializable>();

Check warning on line 160 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

Explicit type arguments can be replaced by Diamond Operator

Use the diamond operator to let the type be inferred automatically. With the Diamond operator it is possible to avoid duplication of the type parameters. Instead, the compiler is now able to infer the parameter types for constructor calls, which makes the code also more readable. The diamond operator has been introduced with java 7. However, type inference has been improved further with java8, rendering more type parameters unnecessary. This is only possible with java8 and the resulting code won't compile with java7. If you use java7, make sure to enable `java7Compatibility` for this rule to avoid false positives. UseDiamondOperator (Priority: 3, Ruleset: Code Style) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#usediamondoperator
nodeProperties.put(QName.createQName("{test}property1"), "value1");

// Create a workspace that contains the 'live' nodes
Expand All @@ -174,10 +174,10 @@
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
this.nodeService.addAspect(this.parentNode, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
HashMap<QName, Serializable> audProps = new HashMap<QName, Serializable>();

Check warning on line 177 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

Explicit type arguments can be replaced by Diamond Operator

Use the diamond operator to let the type be inferred automatically. With the Diamond operator it is possible to avoid duplication of the type parameters. Instead, the compiler is now able to infer the parameter types for constructor calls, which makes the code also more readable. The diamond operator has been introduced with java 7. However, type inference has been improved further with java8, rendering more type parameters unnecessary. This is only possible with java8 and the resulting code won't compile with java7. If you use java7, make sure to enable `java7Compatibility` for this rule to avoid false positives. UseDiamondOperator (Priority: 3, Ruleset: Code Style) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#usediamondoperator
audProps.put(ContentModel.PROP_CREATOR, "Monkey");
this.nodeService.addAspect(this.parentNode, ContentModel.ASPECT_AUDITABLE, audProps);
assertNotNull(this.parentNode);

Check warning on line 180 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

JUnit assertions should include a message

JUnit assertions should include an informative message - i.e., use the three-argument version of assertEquals(), not the two-argument version. JUnitAssertionsShouldIncludeMessage (Priority: 3, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage

// Add some children to the node
this.childNode1 = this.nodeService.createNode(
Expand All @@ -187,7 +187,7 @@
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
this.nodeService.addAspect(this.childNode1, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
assertNotNull(this.childNode1);

Check warning on line 190 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

JUnit assertions should include a message

JUnit assertions should include an informative message - i.e., use the three-argument version of assertEquals(), not the two-argument version. JUnitAssertionsShouldIncludeMessage (Priority: 3, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage
this.childNode2 = this.nodeService.createNode(
this.parentNode,
ContentModel.ASSOC_CHILDREN,
Expand All @@ -195,7 +195,7 @@
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
this.nodeService.addAspect(this.childNode2, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
assertNotNull(this.childNode2);

Check warning on line 198 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

JUnit assertions should include a message

JUnit assertions should include an informative message - i.e., use the three-argument version of assertEquals(), not the two-argument version. JUnitAssertionsShouldIncludeMessage (Priority: 3, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage

// Create a node with no lockAspect
this.noAspectNode = this.nodeService.createNode(
Expand All @@ -204,7 +204,7 @@
QName.createQName("{}noAspectNode"),
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
assertNotNull(this.noAspectNode);

Check warning on line 207 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

JUnit assertions should include a message

JUnit assertions should include an informative message - i.e., use the three-argument version of assertEquals(), not the two-argument version. JUnitAssertionsShouldIncludeMessage (Priority: 3, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage

// Create node with checkedOut
this.checkedOutNode = this.nodeService.createNode(
Expand Down Expand Up @@ -313,7 +313,7 @@
}
catch (UnableToAquireLockException exception)
{
System.out.println(exception.getMessage());

Check failure on line 316 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

System.out.println is used

References to System.(out|err).print are usually intended for debugging purposes and can remain in the codebase even in production code. By using a logger one can enable/disable this behaviour at will (and by priority) and avoid clogging the Standard out log. SystemPrintln (Priority: 2, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#systemprintln
}

TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
Expand Down Expand Up @@ -390,7 +390,7 @@
}
catch (UnableToAquireLockException exception)
{
System.out.println(exception.getMessage());

Check failure on line 393 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

System.out.println is used

References to System.(out|err).print are usually intended for debugging purposes and can remain in the codebase even in production code. By using a logger one can enable/disable this behaviour at will (and by priority) and avoid clogging the Standard out log. SystemPrintln (Priority: 2, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#systemprintln
}

TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
Expand Down Expand Up @@ -705,7 +705,7 @@
}
catch (UnableToReleaseLockException exception)
{
System.out.println(exception.getMessage());

Check failure on line 708 in repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java

View workflow job for this annotation

GitHub Actions / PMD Scan

System.out.println is used

References to System.(out|err).print are usually intended for debugging purposes and can remain in the codebase even in production code. By using a logger one can enable/disable this behaviour at will (and by priority) and avoid clogging the Standard out log. SystemPrintln (Priority: 2, Ruleset: Best Practices) https://pmd.github.io/pmd-6.55.0/pmd_rules_java_bestpractices.html#systemprintln
}

TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -48,11 +48,7 @@
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
viepovsky marked this conversation as resolved.
Show resolved Hide resolved
import static org.mockito.MockitoAnnotations.openMocks;

import java.io.Serializable;
Expand Down Expand Up @@ -97,7 +93,7 @@ public class RuleServiceImplUnitTest
@Mock
private PermissionService permissionService;
@Mock
private SimpleCache nodeRulesCache;
private SimpleCache<NodeRef, List<Rule>> nodeRulesCache;
@Mock
private NodeService runtimeNodeService;
@Mock
Expand Down
41 changes: 21 additions & 20 deletions repository/src/test/resources/test-messaging-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,37 @@
<property name="location" value="test-messaging.properties" />
</bean>

<bean id="transactionAwareEventProducer" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg type="java.lang.Class" value="org.alfresco.repo.rawevents.TransactionAwareEventProducer" />
</bean>

<bean id="policyComponent" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg type="java.lang.Class" value="org.alfresco.repo.policy.PolicyComponentImpl"/>
</bean>

<bean id="transformRequestProcessor" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg type="java.lang.Class" value="org.alfresco.repo.rendition2.TransformRequestProcessor" />
</bean>

<import resource="classpath:/alfresco/subsystems/Messaging/default/messaging-context.xml" />

<bean id="messagingExceptionProcessor"
class="org.alfresco.messaging.camel.MockExceptionProcessor" />

<bean id="mockConsumer"
class="org.alfresco.messaging.camel.MockConsumer" />
<bean id="messagingExceptionProcessor"
class="org.alfresco.messaging.camel.MockExceptionProcessor" />

<bean id="mockConsumer"
class="org.alfresco.messaging.camel.MockConsumer" />

<bean id="mockExceptionThrowingConsumer"
class="org.alfresco.messaging.camel.MockExceptionThrowingConsumer" />

<bean id="mockExceptionThrowingConsumer"
class="org.alfresco.messaging.camel.MockExceptionThrowingConsumer" />

<import resource="testRoutes.xml" />
<bean id="testNewRouteLoader" class="org.alfresco.messaging.camel.SpringContextRouteLoader">
<property name="camelContextId" value="alfrescoCamelContext" />
<property name="routeContextId" value="customRoutes" />
</bean>

<bean id="transactionAwareEventProducer" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.rawevents.TransactionAwareEventProducer" />
</bean>

<bean id="policyComponent" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.policy.PolicyComponentImpl"/>
</bean>

<bean id="renditionEventProcessor" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.rendition2.RenditionEventProcessor"/>
<constructor-arg type="java.lang.Class" value="org.alfresco.repo.rendition2.RenditionEventProcessor"/>
</bean>

<bean id="transformRequestProcessor" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.rendition2.TransformRequestProcessor" />
</bean>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
<beans>

<bean id="repositoryHelper" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.model.Repository" />
<constructor-arg type="java.lang.Class" value="org.alfresco.repo.model.Repository" />
</bean>

<bean id="SiteService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.repo.site.SiteServiceInternal" />
<constructor-arg type="java.lang.Class" value="org.alfresco.repo.site.SiteServiceInternal" />
</bean>

<bean id="NodeService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.cmr.repository.NodeService" />
<constructor-arg type="java.lang.Class" value="org.alfresco.service.cmr.repository.NodeService" />
</bean>

<bean id="NamespaceService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.namespace.NamespaceService" />
<constructor-arg type="java.lang.Class" value="org.alfresco.service.namespace.NamespaceService" />
</bean>

<bean id="SearchService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.cmr.search.SearchService" />
<constructor-arg type="java.lang.Class" value="org.alfresco.service.cmr.search.SearchService" />
</bean>

</beans>