Commit 86a9412f authored by Aman Verma's avatar Aman Verma
Browse files

updating the rest api URI

parent 32c30864
Pipeline #46253 passed with stages
in 24 minutes and 52 seconds
......@@ -30,7 +30,7 @@ import javax.validation.Valid;
@RestController
@RequestMapping("sharedSchema")
@RequestMapping("/schemas/system")
public class AzureSchemaApi {
@Autowired
......@@ -38,16 +38,16 @@ public class AzureSchemaApi {
@PostMapping()
@PreAuthorize("@authorizationFilter.hasRole('" + SchemaAzureConstants.SCHEMA_SERVICE_GROUP_ADMIN + "')")
public ResponseEntity<SchemaInfo> createSharedSchema(@Valid @RequestBody SchemaRequest schemaRequest)
public ResponseEntity<SchemaInfo> createSystemSchema(@Valid @RequestBody SchemaRequest schemaRequest)
throws ApplicationException, BadRequestException {
return new ResponseEntity<>(schemaService.createSharedSchema(schemaRequest), HttpStatus.CREATED);
return new ResponseEntity<>(schemaService.createSystemSchema(schemaRequest), HttpStatus.CREATED);
}
@PutMapping()
@PreAuthorize("@authorizationFilter.hasRole('" + SchemaAzureConstants.SCHEMA_SERVICE_GROUP_ADMIN + "')")
public ResponseEntity<SchemaInfo> upsertSharedSchema(@Valid @RequestBody SchemaRequest schemaRequest)
public ResponseEntity<SchemaInfo> upsertSystemSchema(@Valid @RequestBody SchemaRequest schemaRequest)
throws ApplicationException, BadRequestException {
SchemaUpsertResponse upsertResp = schemaService.upsertSharedSchema(schemaRequest);
SchemaUpsertResponse upsertResp = schemaService.upsertSystemSchema(schemaRequest);
ResponseEntity<SchemaInfo> response = new ResponseEntity<>(upsertResp.getSchemaInfo(), upsertResp.getHttpCode());
return response;
}
......
......@@ -29,7 +29,7 @@ public interface ISchemaServiceAzure {
* @throws ApplicationException
* @throws BadRequestException
*/
SchemaInfo createSharedSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
SchemaInfo createSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
/**
* This method first tries to update the schema with the given schema-id. If there is no schema found,
......@@ -39,5 +39,5 @@ public interface ISchemaServiceAzure {
* @throws ApplicationException
* @throws BadRequestException
*/
SchemaUpsertResponse upsertSharedSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
SchemaUpsertResponse upsertSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException;
}
......@@ -38,12 +38,12 @@ public class SchemaServiceAzure implements ISchemaServiceAzure {
@Value("${shared.tenant.name:system}")
private String sharedTenant;
public SchemaInfo createSharedSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException {
public SchemaInfo createSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException {
updateDataPartitionId();
return schemaServiceCore.createSchema(schemaRequest);
}
public SchemaUpsertResponse upsertSharedSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException {
public SchemaUpsertResponse upsertSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException {
updateDataPartitionId();
return schemaServiceCore.upsertSchema(schemaRequest);
}
......
......@@ -40,8 +40,8 @@ public class AzureSchemaApiTest {
throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException {
schemaRequest = getSchemaRequestObject();
when(schemaServiceAzure.createSharedSchema(schemaRequest)).thenReturn(getSchemaInfoObject());
assertNotNull(schemaServiceAzure.createSharedSchema(schemaRequest));
when(schemaServiceAzure.createSystemSchema(schemaRequest)).thenReturn(getSchemaInfoObject());
assertNotNull(schemaServiceAzure.createSystemSchema(schemaRequest));
}
......@@ -49,8 +49,8 @@ public class AzureSchemaApiTest {
public void testUpsertSchema_update() throws ApplicationException, BadRequestException {
schemaRequest = getSchemaRequestObject();
when(schemaServiceAzure.upsertSharedSchema(schemaRequest)).thenReturn(getSchemaUpsertResponse_Updated());
assertNotNull(azureSchemaApi.upsertSharedSchema(schemaRequest));
when(schemaServiceAzure.upsertSystemSchema(schemaRequest)).thenReturn(getSchemaUpsertResponse_Updated());
assertNotNull(azureSchemaApi.upsertSystemSchema(schemaRequest));
}
......@@ -58,8 +58,8 @@ public class AzureSchemaApiTest {
public void testUpsertSchema_create() throws ApplicationException, BadRequestException {
schemaRequest = getSchemaRequestObject();
when(schemaServiceAzure.upsertSharedSchema(schemaRequest)).thenReturn(getSchemaUpsertResponse_Created());
assertNotNull(azureSchemaApi.upsertSharedSchema(schemaRequest));
when(schemaServiceAzure.upsertSystemSchema(schemaRequest)).thenReturn(getSchemaUpsertResponse_Created());
assertNotNull(azureSchemaApi.upsertSystemSchema(schemaRequest));
}
......@@ -67,8 +67,8 @@ public class AzureSchemaApiTest {
public void testUpsertSchema_Failed() throws ApplicationException, BadRequestException {
schemaRequest = getSchemaRequestObject();
when(schemaServiceAzure.upsertSharedSchema(schemaRequest)).thenThrow(BadRequestException.class);
azureSchemaApi.upsertSharedSchema(schemaRequest);
when(schemaServiceAzure.upsertSystemSchema(schemaRequest)).thenThrow(BadRequestException.class);
azureSchemaApi.upsertSystemSchema(schemaRequest);
}
private SchemaRequest getSchemaRequestObject() {
......
......@@ -69,7 +69,7 @@ public class SchemaServiceAzureTest {
SchemaInfo schemaInfo = getMockSchemaInfo_Published_SharedScope();
Mockito.when(schemaServiceCore.createSchema(schemaRequest)).thenReturn(schemaInfo);
assertEquals(schemaInfo, schemaServiceAzure.createSharedSchema(schemaRequest));
assertEquals(schemaInfo, schemaServiceAzure.createSystemSchema(schemaRequest));
verify(this.headers, times(1)).put(SchemaConstants.DATA_PARTITION_ID, SHARED_TENANT);
}
......@@ -79,7 +79,7 @@ public class SchemaServiceAzureTest {
expectedException.expectMessage(SchemaConstants.SCHEMA_ID_EXISTS);
SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope();
Mockito.when(schemaServiceCore.createSchema(schemaRequest)).thenThrow(new BadRequestException(SchemaConstants.SCHEMA_ID_EXISTS));
schemaServiceAzure.createSharedSchema(schemaRequest);
schemaServiceAzure.createSystemSchema(schemaRequest);
}
@Test
......@@ -89,7 +89,7 @@ public class SchemaServiceAzureTest {
Mockito.when(upsertResponse.getHttpCode()).thenReturn(HttpStatus.OK);
Mockito.when(schemaServiceCore.upsertSchema(schemaRequest)).thenReturn(upsertResponse);
assertEquals(HttpStatus.OK, schemaServiceAzure.upsertSharedSchema(schemaRequest).getHttpCode());
assertEquals(HttpStatus.OK, schemaServiceAzure.upsertSystemSchema(schemaRequest).getHttpCode());
verify(this.headers, times(1)).put(SchemaConstants.DATA_PARTITION_ID, SHARED_TENANT);
verify(this.schemaServiceCore, times(1)).upsertSchema(schemaRequest);
}
......@@ -101,7 +101,7 @@ public class SchemaServiceAzureTest {
Mockito.when(upsertResponse.getHttpCode()).thenReturn(HttpStatus.CREATED);
Mockito.when(schemaServiceCore.upsertSchema(schemaRequest)).thenReturn(upsertResponse);
assertEquals(HttpStatus.CREATED, schemaServiceAzure.upsertSharedSchema(schemaRequest).getHttpCode());
assertEquals(HttpStatus.CREATED, schemaServiceAzure.upsertSystemSchema(schemaRequest).getHttpCode());
verify(this.headers, times(1)).put(SchemaConstants.DATA_PARTITION_ID, SHARED_TENANT);
verify(this.schemaServiceCore, times(1)).upsertSchema(schemaRequest);
}
......@@ -111,7 +111,7 @@ public class SchemaServiceAzureTest {
throws ApplicationException, NotFoundException, BadRequestException {
SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope();
Mockito.when(schemaServiceCore.upsertSchema(schemaRequest)).thenThrow(new BadRequestException());
schemaServiceAzure.upsertSharedSchema(schemaRequest).getHttpCode();
schemaServiceAzure.upsertSystemSchema(schemaRequest).getHttpCode();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment