ProvidenceConfigUtil { static Object getInMessage(PMessage message, String key) throws ProvidenceConfigException { return getInMessage(message, key, null); } private  ProvidenceConfigUtil(); static Path canonicalFileLocation(@Nonnull Path file); static final String UNDEFINED; }
@Test public void testGetInMessage() throws ProvidenceConfigException { assertEquals("44", ProvidenceConfigUtil.getInMessage(declaration, "decl_const.value")); assertEquals("Name", ProvidenceConfigUtil.getInMessage(declaration, "decl_const.name")); assertEquals("44", ProvidenceConfigUtil.getInMessage(declaration, "decl_const.value", "66")); assertEquals(null, ProvidenceConfigUtil.getInMessage(declaration, "decl_const.documentation")); assertThat(ProvidenceConfigUtil.getInMessage(service, "name"), is("stage")); assertThat(ProvidenceConfigUtil.getInMessage(service, "admin"), is(nullValue())); ServicePort def = ServicePort.builder().build(); assertThat(ProvidenceConfigUtil.getInMessage(service, "admin", def), is(sameInstance(def))); }
@Test public void testGetInMessage_fail() { try { ProvidenceConfigUtil.getInMessage(service, "does_not_exist"); fail("No exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Message config.Service has no field named does_not_exist")); } try { ProvidenceConfigUtil.getInMessage(service, "does_not_exist.name"); fail("No exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Message config.Service has no field named does_not_exist")); } try { ProvidenceConfigUtil.getInMessage(service, "db.does_not_exist"); fail("No exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Message config.Database has no field named does_not_exist")); } try { ProvidenceConfigUtil.getInMessage(service, "name.db"); fail("No exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Field 'name' is not of message type in config.Service")); } }