You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/12/11 01:11:58 UTC

[GitHub] [solr] gerlowskija commented on a change in pull request #450: SOLR-15745: Convert create-core v2 API to annotations

gerlowskija commented on a change in pull request #450:
URL: https://github.com/apache/solr/pull/450#discussion_r767067405



##########
File path: solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java
##########
@@ -0,0 +1,146 @@
+/*
+ * 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.solr.handler.admin;
+
+import com.google.common.collect.Maps;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.api.Api;
+import org.apache.solr.api.ApiBag;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.CommandOperation;
+import org.apache.solr.common.util.ContentStreamBase;
+import org.apache.solr.handler.admin.api.CreateCoreAPI;
+import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.apache.solr.common.params.CollectionAdminParams.NUM_SHARDS;
+import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
+import static org.apache.solr.common.params.CommonParams.ACTION;
+import static org.apache.solr.common.params.CoreAdminParams.*;
+import static org.apache.solr.common.params.CoreAdminParams.CoreAdminAction.CREATE;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Unit tests for the /cores APIs.
+ *
+ * Note that the V2 requests made by these tests are not necessarily semantically valid.  They shouldn't be taken as
+ * examples. In several instances, mutually exclusive JSON parameters are provided.  This is done to exercise conversion
+ * of all parameters, even if particular combinations are never expected in the same request.
+ */
+public class V2CoresAPIMappingTest extends SolrTestCaseJ4 {
+    private ApiBag apiBag;
+    private ArgumentCaptor<SolrQueryRequest> queryRequestCaptor;
+    private CoreAdminHandler mockCoreAdminHandler;
+
+    @Before
+    public void setUpMocks() {
+        mockCoreAdminHandler = mock(CoreAdminHandler.class);
+        queryRequestCaptor = ArgumentCaptor.forClass(SolrQueryRequest.class);
+
+        apiBag = new ApiBag(false);
+        apiBag.registerObject(new CreateCoreAPI(mockCoreAdminHandler));
+    }
+
+    @Test
+    public void testCreateCoreAllProperties() throws Exception {
+        final SolrParams v1Params = captureConvertedV1Params("/cores", "POST",
+                "{'create': {" +
+                        "'name': 'someCoreName', " +
+                        "'instanceDir': 'someInstanceDir', " +
+                        "'dataDir': 'someDataDir', " +
+                        "'ulogDir': 'someUpdateLogDirectory', " +
+                        "'schema': 'some-schema-file-name', " +
+                        "'config': 'some-config-file-name', " +
+                        "'configSet': 'someConfigSetName', " +
+                        "'loadOnStartup': true, " +
+                        "'isTransient': true, " +
+                        "'shard': 'someShardName', " +
+                        "'collection': 'someCollectionName', " +
+                        "'replicaType': 'TLOG', " +
+                        "'coreNodeName': 'someNodeName', " +
+                        "'numShards': 123, " +
+                        "'roles': ['role1', 'role2'], " +
+                        "'properties': {'prop1': 'val1', 'prop2': 'val2'}, " +
+                        "'newCollection': true, " +
+                        "'async': 'requestTrackingId' " +
+                        "}}");
+
+        // TODO Delete apispec file

Review comment:
       Haha, yeah, these are remnants from a TODO list I wrote myself at some point.  Will remove.




-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org