Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ob 5273 adopt response to include topic ids #169

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/dockerImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
tags:
- "dockerImage.v.*"
- "v*"
workflow_dispatch:

jobs:
test:
Expand Down Expand Up @@ -182,4 +183,4 @@ jobs:
value: ${{ env.DOCKER_IMAGE_TAG }}
custom-actions: |
- text: View CI
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
4 changes: 4 additions & 0 deletions api/agencyservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ components:
type: integer
format: int64
example: 12
topicIds:
type: array
items:
type: long

FullAgencyResponseDTO:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import de.caritas.cob.agencyservice.api.model.FullAgencyResponseDTO;
import de.caritas.cob.agencyservice.api.repository.agency.Agency;
import de.caritas.cob.agencyservice.api.repository.agency.AgencyRepository;
import de.caritas.cob.agencyservice.api.repository.agencytopic.AgencyTopic;
import de.caritas.cob.agencyservice.api.tenant.TenantContext;
import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO;
import de.caritas.cob.agencyservice.tenantservice.generated.web.model.RestrictedTenantDTO;
Expand Down Expand Up @@ -283,7 +284,8 @@ private AgencyResponseDTO convertToAgencyResponseDTO(Agency agency) {
.teamAgency(agency.isTeamAgency())
.offline(agency.isOffline())
.tenantId(agency.getTenantId())
.consultingType(agency.getConsultingTypeId());
.consultingType(agency.getConsultingTypeId())
.topicIds(agency.getAgencyTopics().stream().map(AgencyTopic::getTopicId).collect(Collectors.toList()));
}


Expand All @@ -300,7 +302,8 @@ private FullAgencyResponseDTO convertToFullAgencyResponseDTO(Agency agency) {
.url(agency.getUrl())
.external(agency.isExternal())
.demographics(getDemographics(agency))
.tenantId(agency.getTenantId());
.tenantId(agency.getTenantId())
.topicIds(agency.getAgencyTopics().stream().map(AgencyTopic::getTopicId).collect(Collectors.toList()));
}

private DemographicsDTO getDemographics(Agency agency) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import de.caritas.cob.agencyservice.api.manager.consultingtype.ConsultingTypeManager;

import de.caritas.cob.agencyservice.api.tenant.TenantContext;
import javax.transaction.Transactional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,13 +27,16 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

@SpringBootTest
@TestPropertySource(properties = "feature.demographics.enabled=true")
@AutoConfigureMockMvc(addFilters = false)
@ActiveProfiles("testing")
@Transactional
class AgencyControllerWithDemographicsIT {

private MockMvc mvc;
Expand Down Expand Up @@ -87,17 +91,22 @@ void getAgencies_Should_ReturnNoContent_When_GenderParamsIsProvidedButNotMatchin

@Test
void getAgencies_Should_ReturnOk_When_MatchingSearchParametersAreProvided() throws Exception {
mvc.perform(
get(PATH_GET_LIST_OF_AGENCIES + "?" + "postcode=99999" + "&"
+ "consultingType=19" + "&" + VALID_AGE_QUERY + "&" + VALID_GENDER_QUERY)
.accept(MediaType.APPLICATION_JSON))
ResultActions perform = mvc.perform(
get(PATH_GET_LIST_OF_AGENCIES + "?" + "postcode=99999" + "&"
+ "consultingType=19" + "&" + VALID_AGE_QUERY + "&" + VALID_GENDER_QUERY)
.accept(MediaType.APPLICATION_JSON));
perform
.andExpect(status().isOk())
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].id").value(1737))
.andExpect(jsonPath("$[0].topicIds").isArray())
.andExpect(jsonPath("$[0].demographics.ageFrom").value(30))
.andExpect(jsonPath("$[0].demographics.ageTo").value(60))
.andExpect(jsonPath("$[0].demographics.genders[0]").value("FEMALE"))
.andExpect(jsonPath("$[0].demographics.genders[1]").value("DIVERS"));
MvcResult mvcResult = perform.andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.assertj.core.util.Lists;

public class TestConstants {

Expand Down Expand Up @@ -177,7 +178,8 @@ public class TestConstants {
public static final AgencyResponseDTO AGENCY_RESPONSE_DTO =
new AgencyResponseDTO().id(AGENCY_ID).name(AGENCY_NAME).postcode(POSTCODE)
.city(AGENCY_CITY).description(AGENCY_DESCRIPTION).teamAgency(false).offline(false)
.consultingType(CONSULTING_TYPE_SUCHT);
.consultingType(CONSULTING_TYPE_SUCHT)
.topicIds(Lists.newArrayList(1L, 2L));
public static final List<AgencyResponseDTO> AGENCY_RESPONSE_DTO_LIST = Collections.singletonList(
AGENCY_RESPONSE_DTO);
public static final FullAgencyResponseDTO FULL_AGENCY_RESPONSE_DTO =
Expand Down