Skip to content
Snippets Groups Projects
Commit 7147f34b authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

refactor

parent 18612105
No related branches found
No related tags found
2 merge requests!346Merge branch 'aws-integration' into 'master',!282disable default index creation
......@@ -14,7 +14,6 @@
package org.opengroup.osdu.indexer.api;
import lombok.extern.java.Log;
import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.service.IClusterConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,12 +27,10 @@ import org.springframework.web.context.annotation.RequestScope;
import java.io.IOException;
import java.util.ArrayList;
@Log
@RestController
@RequestMapping("/partitions/settings")
@RequestMapping("/partitions")
@RequestScope
public class DataPartitionSettingsApi {
public class DataPartitionSetupApi {
private static final String OPS = "users.datalake.ops";
......@@ -43,7 +40,7 @@ public class DataPartitionSettingsApi {
private AuditLogger auditLogger;
@PreAuthorize("@authorizationFilter.hasPermission('" + OPS + "')")
@PostMapping
@PostMapping(path = "/cluster-settings", consumes = "application/json")
public ResponseEntity<?> partitionInit() throws IOException {
this.clusterConfigurationService.updateClusterConfiguration();
this.auditLogger.getConfigurePartition(new ArrayList<>());
......
// Copyright © Schlumberger
//
// Licensed 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.opengroup.osdu.indexer.api;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.service.IClusterConfigurationService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
public class DataPartitionSetupApiTest {
@Mock
private AuditLogger auditLogger;
@Mock
private IClusterConfigurationService clusterConfigurationService;
@InjectMocks
private DataPartitionSetupApi sut;
@Test
public void should_return200_when_valid_kind_provided() throws IOException {
ResponseEntity<?> response = this.sut.partitionInit();
assertEquals(HttpStatus.OK, response.getStatusCode());
}
@Test(expected = AppException.class)
public void should_throwAppException_ifUnknownExceptionCaught_reindexTest() throws IOException {
when(this.clusterConfigurationService.updateClusterConfiguration()).thenThrow(new AppException(500, "", ""));
this.sut.partitionInit();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment