### Question:
RequestHandlerUtils extends AbstractRestHandler { protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir) { String serviceInstanceId = null; if (sir.getServiceInstanceId() != null) { serviceInstanceId = sir.getServiceInstanceId(); } else { Optional<String> serviceInstanceIdForInstance = getServiceInstanceIdForInstanceGroup(requestScope, sir); if (serviceInstanceIdForInstance.isPresent()) { serviceInstanceId = serviceInstanceIdForInstance.get(); } } return serviceInstanceId; }  Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter,
            String orchestrationUri, String requestScope); @Override void updateStatus(InfraActiveRequests aq, Status status, String errorMessage); String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri); void validateHeaders(ContainerRequestContext context); String getRequestUri(ContainerRequestContext context, String uriPrefix); void checkForDuplicateRequests(Actions action, HashMap<String, String> instanceIdMap, String requestScope,
            InfraActiveRequests currentActiveReq, String instanceName); InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, String instanceName,
            String requestScope, InfraActiveRequests currentActiveReq); boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq); ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action,
            String requestId, String requestUri); void parseRequest(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action,
            String version, String requestJSON, Boolean aLaCarte, String requestId,
            InfraActiveRequests currentActiveReq); void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action,
            Map<String, String> instanceIdMap, String instanceName, String requestScope, InfraActiveRequests dup); @Override String getRequestId(ContainerRequestContext requestContext); void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId,
            Map<String, String> instanceIdMap); String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest,
            boolean isAlaCarte, Actions action); Optional<String> retrieveModelName(RequestParameters requestParams); String getDefaultModel(ServiceInstancesRequest sir); String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag); RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action,
            boolean alaCarteFlag, InfraActiveRequests currentActiveReq);  }### Answer:
@Test public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException { String requestScope = "instanceGroup"; ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class); assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", requestHandlerUtils.setServiceInstanceId(requestScope, sir)); }
@Test public void setServiceInstanceIdTest() { String requestScope = "vnf"; ServiceInstancesRequest sir = new ServiceInstancesRequest(); sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f"); assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", requestHandlerUtils.setServiceInstanceId(requestScope, sir)); }
@Test public void setServiceInstanceIdReturnNullTest() { String requestScope = "vnf"; ServiceInstancesRequest sir = new ServiceInstancesRequest(); assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir)); }