### Question:
AbstractRestHandler { public Optional<URL> buildSelfLinkUrl(String url, String requestId) { Optional<URL> selfLinkUrl = Optional.empty(); String version = ""; try { URL aUrl = new URL(url); String aPath = aUrl.getPath(); int indexOfVersion = Math.max(aPath.indexOf("/V"), aPath.indexOf("/v")); version = aPath.substring(indexOfVersion, indexOfVersion + 4); String pathWithSOAction = aPath.substring(0, indexOfVersion); String pathWithoutSOAction = pathWithSOAction.substring(0, pathWithSOAction.lastIndexOf("/")); String selfLinkPath = pathWithoutSOAction.concat(Constants.ORCHESTRATION_REQUESTS_PATH).concat(version).concat(requestId); selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath)); } catch (Exception e) { selfLinkUrl = Optional.empty(); logger.error("Exception in buildSelfLinkUrl", e); } return selfLinkUrl; }  String getRequestUri(ContainerRequestContext context); String getRequestId(ContainerRequestContext requestContext); InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, long startTime,
            MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq); InfraActiveRequests duplicateCheck(Actions action, Map<String, String> instanceIdMap, long startTime,
            String instanceName, String requestScope, InfraActiveRequests currentActiveReq); void updateStatus(InfraActiveRequests aq, Status status, String errorMessage); void callWorkflowEngine(RequestClientParameter requestClientParameter, String orchestrationUri); Optional<URL> buildSelfLinkUrl(String url, String requestId); ServiceInstancesResponse createResponse(String instanceId, String requestId,
            ContainerRequestContext requestContext); void checkDuplicateRequest(Map<String, String> instanceIdMap, ModelType modelType, String instanceName,
            String requestId); static final String CONFLICT_FAIL_MESSAGE; }### Answer:
@Test public void test_buildSelfLinkUrl() throws MalformedURLException { String initialLink = "http: String requestId = "4d0437c3-ee48-4361-a4f7-e1613c82493a"; Optional<URL> expectedLink = Optional.of(new URL( "http: Optional<URL> resultURL = restHandler.buildSelfLinkUrl(initialLink, requestId); assertThat(resultURL, sameBeanAs(expectedLink)); }