FrameworkIDService { public Optional<String> fetch() { String frameworkId = regCenter.getDirectly(HANode.FRAMEWORK_ID_NODE); return Strings.isNullOrEmpty(frameworkId) ? Optional.empty() : Optional.of(frameworkId); }  Optional<String> fetch(); void save(final String id);  }
@Test public void assertFetch() { when(registryCenter.getDirectly(HANode.FRAMEWORK_ID_NODE)).thenReturn("1"); Optional<String> frameworkIDOptional = frameworkIDService.fetch(); assertTrue(frameworkIDOptional.isPresent()); assertThat(frameworkIDOptional.get(), is("1")); verify(registryCenter).getDirectly(HANode.FRAMEWORK_ID_NODE); }