ExternalDependencies { public List<ExternalDependency> getDependencies() { return dependencies != null ? dependencies : emptyList(); }  List<ExternalDependency> getDependencies();  }
@Test public void shouldReturnEmptyDependencies() throws Exception { when(externalDependencies.getDependencies()).thenReturn(emptyList()); mockMvc.perform(get("/internal/dependencies").accept(APPLICATION_JSON)) .andExpect(status().is2xxSuccessful()) .andExpect( jsonPath("@.dependencies").isArray() ) .andExpect( jsonPath("@.dependencies").isEmpty() ); }
@Test public void shouldReturnDependencies() throws Exception { when(externalDependencies.getDependencies()).thenReturn(asList( mongoDependency(singletonList(datasource("foo:42/bar"))).withName("test").build(), restServiceDependency("foobar:4711").build() )); mockMvc.perform(get("/internal/dependencies").accept(APPLICATION_JSON)) .andExpect(status().is2xxSuccessful()) .andExpect( jsonPath("@.dependencies").isArray() ) .andExpect( jsonPath("@.dependencies[0].datasources").isArray() ) .andExpect( jsonPath("@.dependencies[0].datasources[0]").value("foo:42/bar") ) .andExpect( jsonPath("@.dependencies[0].url").doesNotExist() ) .andExpect( jsonPath("@.dependencies[0].name").value("test") ) .andExpect( jsonPath("@.dependencies[0].type").value("db") ) .andExpect( jsonPath("@.dependencies[0].subtype").value("MongoDB") ) .andExpect( jsonPath("@.dependencies[1].url").value("foobar:4711") ) .andExpect( jsonPath("@.dependencies[1].type").value("service") ) .andExpect( jsonPath("@.dependencies[1].subtype").value("REST") ) .andExpect( jsonPath("@.dependencies[1].datasources").doesNotExist() ) ; }
@Test public void shouldReturnCriticalityAndExpectations() throws Exception { when(externalDependencies.getDependencies()).thenReturn(asList( mongoDependency(singletonList(datasource("foo:42/bar"))).build(), restServiceDependency("foobar:4711") .withCriticality(criticality(HIGH, "Bad. Really bad.")) .withExpectations(lowExpectations()) .build() )); mockMvc.perform(get("/internal/dependencies").accept(APPLICATION_JSON)) .andExpect( jsonPath("@.dependencies[0].criticality.level").value("NOT_SPECIFIED") ) .andExpect( jsonPath("@.dependencies[0].criticality.disasterImpact").value("Not Specified") ) .andExpect( jsonPath("@.dependencies[0].expectations.availability").value("NOT_SPECIFIED") ) .andExpect( jsonPath("@.dependencies[0].expectations.performance").value("NOT_SPECIFIED") ) .andExpect( jsonPath("@.dependencies[1].criticality.level").value("HIGH") ) .andExpect( jsonPath("@.dependencies[1].criticality.disasterImpact").value("Bad. Really bad.") ) .andExpect( jsonPath("@.dependencies[1].expectations.availability").value("LOW") ) .andExpect( jsonPath("@.dependencies[1].expectations.performance").value("LOW") ); }