/** * Select the children or the leaves of a base component, given by its UUID. The components that are not present in last * analysis are ignored. * <p> * An empty list is returned if the base component does not exist or if the base component is a leaf. */ public List<ComponentDto> selectDescendants(DbSession dbSession, ComponentTreeQuery query) { Optional<ComponentDto> componentOpt = selectByUuid(dbSession, query.getBaseUuid()); if (!componentOpt.isPresent()) { return emptyList(); } ComponentDto component = componentOpt.get(); return mapper(dbSession).selectDescendants(query, componentOpt.get().uuid(), query.getUuidPath(component)); }
@Test public void create_query() { ComponentTreeQuery query = ComponentTreeQuery.builder() .setBaseUuid(BASE_UUID) .setStrategy(CHILDREN) .setQualifiers(asList("FIL", "DIR")) .setNameOrKeyQuery("teSt") .build(); assertThat(query.getBaseUuid()).isEqualTo(BASE_UUID); assertThat(query.getStrategy()).isEqualTo(CHILDREN); assertThat(query.getQualifiers()).containsOnly("FIL", "DIR"); assertThat(query.getNameOrKeyQuery()).isEqualTo("teSt"); assertThat(query.getNameOrKeyUpperLikeQuery()).isEqualTo("%TEST%"); }
@Test public void create_minimal_query() { ComponentTreeQuery query = ComponentTreeQuery.builder() .setBaseUuid(BASE_UUID) .setStrategy(CHILDREN) .build(); assertThat(query.getBaseUuid()).isEqualTo(BASE_UUID); assertThat(query.getStrategy()).isEqualTo(CHILDREN); assertThat(query.getQualifiers()).isNull(); assertThat(query.getNameOrKeyQuery()).isNull(); assertThat(query.getNameOrKeyUpperLikeQuery()).isNull(); }
/** * Select the children or the leaves of a base component, given by its UUID. The components that are not present in last * analysis are ignored. * * An empty list is returned if the base component does not exist or if the base component is a leaf. */ public List<ComponentDto> selectDescendants(DbSession dbSession, ComponentTreeQuery query) { Optional<ComponentDto> componentOpt = selectByUuid(dbSession, query.getBaseUuid()); if (!componentOpt.isPresent()) { return emptyList(); } ComponentDto component = componentOpt.get(); return mapper(dbSession).selectDescendants(query, componentOpt.get().uuid(), query.getUuidPath(component)); }