From d393df01368a23a98a39ec093f2bd627f17043dd Mon Sep 17 00:00:00 2001 From: cagache Date: Wed, 21 Aug 2019 18:38:37 +0300 Subject: [PATCH] fix tests --- .../util/NodeTypeUtilityUnitTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtilityUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtilityUnitTest.java index eceac23478..7b6d0eef6d 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtilityUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtilityUnitTest.java @@ -26,6 +26,8 @@ */ package org.alfresco.module.org_alfresco_module_rm.util; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -69,7 +71,7 @@ public class NodeTypeUtilityUnitTest public void testNotInstanceOf() { when(mockedDictionaryService.isSubClass(type, ofType)).thenReturn(false); - when(nodeTypeUtility.instanceOf(type, ofType)).thenReturn(false); + assertFalse(nodeTypeUtility.instanceOf(type, ofType)); } /** test that instanceOf returns true if verified type is subtype of the other */ @@ -77,7 +79,7 @@ public class NodeTypeUtilityUnitTest public void testIsInstanceOf() { when(mockedDictionaryService.isSubClass(type, ofType)).thenReturn(true); - when(nodeTypeUtility.instanceOf(type, ofType)).thenReturn(true); + assertTrue(nodeTypeUtility.instanceOf(type, ofType)); } /** test that instanceOf checks the cache when verifying the same type twice */ @@ -85,7 +87,19 @@ public class NodeTypeUtilityUnitTest public void testInstanceOfCacheSameTypes() { nodeTypeUtility.instanceOf(type, ofType); + verify(mockedDictionaryService, times(1)).isSubClass(any(), any()); nodeTypeUtility.instanceOf(type, ofType); verify(mockedDictionaryService, times(1)).isSubClass(any(), any()); } + + /** test the invocations when verifying different types */ + @Test + public void testInstanceOfDifferentTypes() + { + QName anotherType = AlfMock.generateQName(); + nodeTypeUtility.instanceOf(type, ofType); + verify(mockedDictionaryService, times(1)).isSubClass(any(), any()); + nodeTypeUtility.instanceOf(anotherType, ofType); + verify(mockedDictionaryService, times(2)).isSubClass(any(), any()); + } }