### Question:
DomainUtils { public static DomainTypeResolver devToolsProtocolResolver(DevToolsProtocol protocol) { return ((domain, object) -> { for (Domain protocolDomain : protocol.getDomains()) { if (protocolDomain.getDomain().equals(domain)) { for (Type type : protocolDomain.getTypes()) { if (type.getId().equals(object)) { return type; } } throw new RuntimeException("Type " + object + " on domain " + domain + " not found!"); } } throw new RuntimeException("Type " + object + " on domain " + domain + " not found!"); }); }  static DomainTypeResolver devToolsProtocolResolver(DevToolsProtocol protocol);  }### Answer:
@Test(expected = RuntimeException.class) public void testDevToolsProtocolResolverOnNonExistingDomain() { DevToolsProtocol devToolsProtocol = new DevToolsProtocol(); devToolsProtocol.setDomains(Collections.emptyList()); DomainUtils.devToolsProtocolResolver(devToolsProtocol).resolve("domain", "test"); }
@Test(expected = RuntimeException.class) public void testDevToolsProtocolResolverOnNonExistingType() { Type type1 = new StringType(); type1.setId("test-type"); Type type2 = new StringType(); type2.setId("test-type"); Domain domain = new Domain(); domain.setDomain("domain"); domain.setTypes(Arrays.asList(type1, type2)); DevToolsProtocol devToolsProtocol = new DevToolsProtocol(); devToolsProtocol.setDomains(Collections.singletonList(domain)); DomainUtils.devToolsProtocolResolver(devToolsProtocol).resolve("domain", "test"); }
@Test public void testDevToolsProtocolResolver() { Type type = new StringType(); type.setId("test"); Domain domain = new Domain(); domain.setDomain("domain"); domain.setTypes(Collections.singletonList(type)); DevToolsProtocol devToolsProtocol = new DevToolsProtocol(); devToolsProtocol.setDomains(Collections.singletonList(domain)); Type resolvedType = DomainUtils.devToolsProtocolResolver(devToolsProtocol).resolve("domain", "test"); assertEquals(type, resolvedType); }