GlobalConfigResourceImpl implements GlobalConfigResource { @Timed @Override public ListConfigResponse list(final GlobalConfigCriteria criteria) { return globalConfigService.list(criteria); } @Inject  GlobalConfigResourceImpl(final GlobalConfigService globalConfigService,
                             final NodeService nodeService,
                             final UiConfig uiConfig,
                             final NodeInfo nodeInfo,
                             final WebTargetFactory webTargetFactory,
                             final UriFactory uriFactory); @Timed @Override ListConfigResponse list(final GlobalConfigCriteria criteria); @Timed @Override ListConfigResponse listByNode(final String nodeName,
                                         final GlobalConfigCriteria criteria); @Timed @Override ConfigProperty getPropertyByName(final String propertyPath); @Timed OverrideValue<String> getYamlValueByName(final String propertyPath); @Timed @Override OverrideValue<String> getYamlValueByNodeAndName(final String propertyName,
                                                           final String nodeName); @Timed @Override ConfigProperty create(final ConfigProperty configProperty); @Timed @Override ConfigProperty update(final String propertyName, final ConfigProperty configProperty); @Timed @Override UiConfig fetchUiConfig();  }
@Test void list() { initNodes(); final String subPath = GlobalConfigResource.PROPERTIES_SUB_PATH; final ListConfigResponse expectedResponse = FULL_PROP_LIST; doPostTest(subPath, new GlobalConfigCriteria(), ListConfigResponse.class, expectedResponse); verify(globalConfigServiceMap.get("node1"), times(1)) .list(eq(new GlobalConfigCriteria())); }
@Test void list_partialName() { initNodes(); final String subPath = GlobalConfigResource.PROPERTIES_SUB_PATH; final ConfigProperty configProperty = new ConfigProperty(CONFIG_PROPERTY_2.getName()); configProperty.setYamlOverrideValue("node1"); final ListConfigResponse expectedResponse = new ListConfigResponse(List.of( configProperty )); final GlobalConfigCriteria criteria = new GlobalConfigCriteria("some"); doPostTest(subPath, criteria, ListConfigResponse.class, expectedResponse); verify(globalConfigServiceMap.get("node1"), times(1)) .list(eq(criteria)); }
@Test void listByNode_thisNode() { initNodes(); final String subPath = ResourcePaths.buildPath( GlobalConfigResource.NODE_PROPERTIES_SUB_PATH, "node1"); final ListConfigResponse expectedResponse = FULL_PROP_LIST; doPostTest( subPath, new GlobalConfigCriteria(), ListConfigResponse.class, expectedResponse); verify(globalConfigServiceMap.get("node1"), times(1)) .list(new GlobalConfigCriteria()); Assertions.assertThat(getRequestEvents("node1")) .hasSize(1); Assertions.assertThat(getRequestEvents("node2")) .hasSize(0); Assertions.assertThat(getRequestEvents("node3")) .hasSize(0); }
@Test void listByNode_otherNode() { initNodes(); final String subPath = ResourcePaths.buildPath( GlobalConfigResource.NODE_PROPERTIES_SUB_PATH, "node2"); final ListConfigResponse expectedResponse = FULL_PROP_LIST; doPostTest( subPath, new GlobalConfigCriteria(), ListConfigResponse.class, expectedResponse); verify(globalConfigServiceMap.get("node2"), times(1)) .list(eq(new GlobalConfigCriteria())); Assertions.assertThat(getRequestEvents("node1")) .hasSize(1); Assertions.assertThat(getRequestEvents("node2")) .hasSize(1); Assertions.assertThat(getRequestEvents("node3")) .hasSize(0); }