Fix context path of the API getFeaturesOfDevice

group-operation
Arshana 2 years ago committed by prathabanKavin
parent 7f327bac08
commit b797ed1f5b

@ -1209,7 +1209,7 @@ public interface DeviceManagementService {
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{type}/{id}/features")
@Path("/device-type/{type}/features")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
@ -1280,14 +1280,6 @@ public interface DeviceManagementService {
@PathParam("type")
@Size(max = 45)
String type,
@ApiParam(
name = "id",
value = "The device identifier of the device.\n" +
"INFO: Make sure to add the ID of a device that is already registered with WSO2 IoTS.",
required = true)
@PathParam("id")
@Size(max = 45)
String id,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time. \n" +

@ -890,16 +890,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
@GET
@Path("/{type}/{id}/features")
@Path("/device-type/{type}/features")
@Override
public Response getFeaturesOfDevice(
@PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
List<Feature> features = new ArrayList<>();
DeviceManagementProviderService dms;
try {
RequestValidationUtil.validateDeviceIdentifier(type, id);
dms = DeviceMgtAPIUtils.getDeviceManagementService();
FeatureManager fm;
try {
@ -913,8 +911,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
features = fm.getFeatures();
}
} catch (DeviceManagementException e) {
String msg = "Error occurred while retrieving the list of features of '" + type + "' device, which " +
"carries the id '" + id + "'";
String msg = "Error occurred while retrieving the list of features of '" + type + "'";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();

@ -590,7 +590,7 @@ public class DeviceManagementServiceImplTest {
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
.toReturn(this.deviceManagementProviderService);
Response response = this.deviceManagementService
.getFeaturesOfDevice(TEST_DEVICE_TYPE, UUID.randomUUID().toString(), null);
.getFeaturesOfDevice(TEST_DEVICE_TYPE, null);
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
@ -601,7 +601,7 @@ public class DeviceManagementServiceImplTest {
Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString()))
.thenThrow(new DeviceTypeNotFoundException());
Response response = this.deviceManagementService
.getFeaturesOfDevice(TEST_DEVICE_TYPE, UUID.randomUUID().toString(), null);
.getFeaturesOfDevice(TEST_DEVICE_TYPE, null);
Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
Mockito.reset(this.deviceManagementProviderService);
}

Loading…
Cancel
Save