OEmbedUrlProcessor implements UrlProcessor { @Override public Result process(String url) { if (oEmbedClient == null || StringUtils.isEmpty(url)) { return null; } String provider = oEmbedClient.getProvider(url); if (StringUtils.isEmpty(provider)) { return null; } OEmbedResponse oEmbedResponse = oEmbedClient.getResponse(url); if (oEmbedResponse == null) { return null; } boolean unsafeContext = oEmbedClient.isUnsafeContext(url); return new UrlProcessorResultImpl( NAME, new HashMap<String, Object>() {{ put("provider", provider); put("response", oEmbedResponse); put("unsafeContext", unsafeContext); }}); }  @Override Result process(String url);  }
@Test void test() { OEmbedUrlProcessor processor = new OEmbedUrlProcessor(); OEmbedClient mockClient = Mockito.mock(OEmbedClient.class); Mockito.when(mockClient.getProvider("something")).thenReturn("Test"); Mockito.when(mockClient.getResponse("something")).thenReturn(new OEmbedJSONResponseImpl()); processor.oEmbedClient = mockClient; UrlProcessor.Result result = processor.process("something"); assertNotNull(result); assertEquals(OEmbedUrlProcessor.NAME, result.getProcessor()); assertEquals("Test", result.getOptions().get("provider")); assertNotNull(result.getOptions().get("response")); assertNull(processor.process("anything")); }