### Question:
ResourceExtensionResolver { public String generateMappingKey() { final StringBuilder builder = new StringBuilder(); final String requestAsString = getHttpServletRequest().getRequestURI(); final String pathTemplate = StringUtils.substringAfter(requestAsString, API_EXTENSION_TEMPLATE_PREFIX); builder.append(MAPPING_KEY_PREFIX) .append(MAPPING_KEY_SEPARATOR) .append(request.getMethod().getName()) .append(MAPPING_KEY_SEPARATOR) .append(pathTemplate); return builder.toString(); } ResourceExtensionResolver(Request request, PageMappingService pageMappingService); Long resolvePageId(APISession apiSession); String generateMappingKey(); File resolveRestApiControllerFile(PageResourceProviderImpl pageResourceProvider); static final String MAPPING_KEY_SEPARATOR; static final String MAPPING_KEY_PREFIX; static final String API_EXTENSION_TEMPLATE_PREFIX; }### Answer:
@Test public void should_generate_mapping_key() throws Exception { final Request request = new Request(Method.POST, "/bonita/API/extension/myPostResource"); final ResourceExtensionResolver resourceExtensionResolver = createSpy(request, "/bonita/API/extension/myPostResource"); final String mappingKey = resourceExtensionResolver.generateMappingKey(); assertThat(mappingKey).isEqualTo(API_EXTENSION_POST_MAPPING_KEY); }
@Test public void should_mapping_key_exclude_parameters() throws Exception { final Request request = new Request(Method.GET, "/bonita/API/extension/helloWorld?param1=a&param2=b"); final ResourceExtensionResolver resourceExtensionResolver = createSpy(request, "/bonita/API/extension/helloWorld"); final String mappingKey = resourceExtensionResolver.generateMappingKey(); assertThat(mappingKey).isEqualTo(API_EXTENSION_GET_MAPPING_KEY); }