diff --git a/search-services/alfresco-search/src/test/java/org/alfresco/solr/AlfrescoCoreAdminHandlerTest.java b/search-services/alfresco-search/src/test/java/org/alfresco/solr/AlfrescoCoreAdminHandlerTest.java index 6e076963a..955f365b5 100644 --- a/search-services/alfresco-search/src/test/java/org/alfresco/solr/AlfrescoCoreAdminHandlerTest.java +++ b/search-services/alfresco-search/src/test/java/org/alfresco/solr/AlfrescoCoreAdminHandlerTest.java @@ -20,8 +20,13 @@ package org.alfresco.solr; import static java.util.Arrays.asList; +import static org.alfresco.solr.AlfrescoCoreAdminHandler.ALFRESCO_CORE_NAME; +import static org.alfresco.solr.AlfrescoCoreAdminHandler.ARCHIVE_CORE_NAME; import static org.alfresco.solr.AlfrescoCoreAdminHandler.ARG_TXID; +import static org.alfresco.solr.AlfrescoCoreAdminHandler.STORE_REF_MAP; +import static org.alfresco.solr.AlfrescoCoreAdminHandler.VERSION_CORE_NAME; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; @@ -186,13 +191,13 @@ public class AlfrescoCoreAdminHandlerTest // First let's try a list of invalid names, one by one List invalidNames = - AlfrescoCoreAdminHandler.STORE_REF_MAP.keySet().stream() + STORE_REF_MAP.keySet().stream() .map(coreName -> coreName + System.currentTimeMillis()) .collect(Collectors.toList()); invalidNames.forEach(spy::setupNewDefaultCores); - verify(spy, never()).newDefaultCore(anyString(), any(), anyString(), any(), any()); + verify(spy, never()).newCore(any(), anyInt(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any(), any()); reset(spy); @@ -200,14 +205,14 @@ public class AlfrescoCoreAdminHandlerTest String commaSeparatedNames = String.join(",", invalidNames); spy.setupNewDefaultCores(commaSeparatedNames); - verify(spy, never()).newDefaultCore(anyString(), any(), anyString(), any(), any()); + verify(spy, never()).newCore(any(), anyInt(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any(), any()); } @Test public void coreNamesAreTrimmed_oneCoreNameAtTime() { AlfrescoCoreAdminHandler spy = spy(new AlfrescoCoreAdminHandler() { @Override - protected boolean newDefaultCore(String coreName, StoreRef storeRef, String templateName, Properties extraProperties, SolrQueryResponse rsp) + protected boolean newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties, SolrQueryResponse rsp) { // Do nothing here otherwise we cannot spy it return true; @@ -217,23 +222,23 @@ public class AlfrescoCoreAdminHandlerTest // First let's try a list of names, one by one final List coreNames = asList( - AlfrescoCoreAdminHandler.ARCHIVE_CORE_NAME + " ", // whitespace char at the end - "\t " + AlfrescoCoreAdminHandler.ALFRESCO_CORE_NAME, // whitespace chars at the beginning - " " + AlfrescoCoreAdminHandler.VERSION_CORE_NAME + " \t", // beginning and end + ARCHIVE_CORE_NAME + " ", // whitespace char at the end + "\t " + ALFRESCO_CORE_NAME, // whitespace chars at the beginning + " " + VERSION_CORE_NAME + " \t", // beginning and end " \t"); // empty name coreNames.forEach(spy::setupNewDefaultCores); - verify(spy).newDefaultCore(eq(AlfrescoCoreAdminHandler.ARCHIVE_CORE_NAME), any(), anyString(), any(), any()); - verify(spy).newDefaultCore(eq(AlfrescoCoreAdminHandler.ALFRESCO_CORE_NAME), any(), anyString(), any(), any()); - verify(spy).newDefaultCore(eq(AlfrescoCoreAdminHandler.VERSION_CORE_NAME), any(), anyString(), any(), any()); + verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any()); + verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any()); + verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any()); } @Test public void validAndInvalidCoreNames() { AlfrescoCoreAdminHandler spy = spy(new AlfrescoCoreAdminHandler() { @Override - protected boolean newDefaultCore(String coreName, StoreRef storeRef, String templateName, Properties extraProperties, SolrQueryResponse rsp) + protected boolean newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties, SolrQueryResponse rsp) { // Do nothing here otherwise we cannot spy it return true; @@ -243,17 +248,17 @@ public class AlfrescoCoreAdminHandlerTest // First let's try a list of names, one by one final List coreNames = asList( - AlfrescoCoreAdminHandler.ARCHIVE_CORE_NAME + " ", // whitespace char at the end - "\t " + AlfrescoCoreAdminHandler.ALFRESCO_CORE_NAME, // whitespace chars at the beginning - " " + AlfrescoCoreAdminHandler.VERSION_CORE_NAME + " \t", // beginning and end + ARCHIVE_CORE_NAME + " ", // whitespace char at the end + "\t " + ALFRESCO_CORE_NAME, // whitespace chars at the beginning + " " + VERSION_CORE_NAME + " \t", // beginning and end " \t"); // empty name // Then, the same list as a single parameter (e.g. name1, name2, name3, etc) String commaSeparatedNames = String.join(",", coreNames); spy.setupNewDefaultCores(commaSeparatedNames); - verify(spy).newDefaultCore(eq(AlfrescoCoreAdminHandler.ARCHIVE_CORE_NAME), any(), anyString(), any(), any()); - verify(spy).newDefaultCore(eq(AlfrescoCoreAdminHandler.ALFRESCO_CORE_NAME), any(), anyString(), any(), any()); - verify(spy).newDefaultCore(eq(AlfrescoCoreAdminHandler.VERSION_CORE_NAME), any(), anyString(), any(), any()); + verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any()); + verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any()); + verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any()); } } \ No newline at end of file