Skip to content

Commit

Permalink
feat: CARITAS-286
Browse files Browse the repository at this point in the history
* add new unit tests for the AgencyService
  • Loading branch information
Leandro13Silva13 committed Oct 30, 2024
1 parent a81ced7 commit 7f44d8f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_ID;
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_IDS_LIST;
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_LIST;
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_LIST_WITH_TOPICS;
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_OFFLINE;
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_ONLINE_U25;
import static de.caritas.cob.agencyservice.testHelper.TestConstants.AGENCY_RESPONSE_DTO;
Expand Down Expand Up @@ -358,4 +359,23 @@ public void getAgenciesTopics_Should_ReturnEmptyListOfTopicIds_When_topicsDontEx

assertThat(result).isEmpty();
}

@Test
public void getAgencies_WithOnlyPostCodeAndTopicId_Should_ReturnEmptyList_When_NoAgencyFound() {

assertThat(agencyService.getAgencies("99999", 1),
IsEmptyCollection.empty());
}

@Test
public void getAgencies_WithOnlyPostCodeAndTopicId_Should_ReturnResultList_When_AgencyFound() {

when(agencyRepository.searchWithTopic("99999", 5, null,
1, null, null, null, null))
.thenReturn(AGENCY_LIST_WITH_TOPICS);

var result = agencyService.getAgencies("99999", 1);

assertThat(result).isNotEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.caritas.cob.agencyservice.api.model.AgencyTopicsDTO;
import de.caritas.cob.agencyservice.api.model.FullAgencyResponseDTO;
import de.caritas.cob.agencyservice.api.repository.agency.Agency;
import de.caritas.cob.agencyservice.api.repository.agencytopic.AgencyTopic;
import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -166,6 +167,26 @@ public class TestConstants {
.isExternal(false)
.build();

public static final Long TOPIC_ID = 1L;

public static final AgencyTopic AGENCY_TOPIC = AgencyTopic.builder()
.topicId(TOPIC_ID)
.agency(AGENCY_SUCHT)
.build();

public static final Agency AGENCY_SUCHT_WITH_TOPICS = Agency.builder()
.id(AGENCY_ID)
.name(AGENCY_NAME)
.description(AGENCY_DESCRIPTION)
.postCode(POSTCODE)
.city("Test city")
.teamAgency(false)
.consultingTypeId(CONSULTING_TYPE_SUCHT)
.offline(false)
.isExternal(false)
.agencyTopics(Collections.singletonList(AGENCY_TOPIC))
.build();

public static final Integer TOPIC_SUCHT = 1;

public static final Agency AGENCY_KREUZBUND = new Agency(AGENCY_ID, AGENCY_NAME,
Expand Down Expand Up @@ -206,6 +227,7 @@ public class TestConstants {

public static final List<Agency> EMPTY_AGENCY_LIST = new ArrayList<>();
public static final List<Agency> AGENCY_LIST = Collections.singletonList(AGENCY_SUCHT);
public static final List<Agency> AGENCY_LIST_WITH_TOPICS = Collections.singletonList(AGENCY_SUCHT_WITH_TOPICS);
public static final List<Integer> TOPIC_ID_LIST = Collections.singletonList(TOPIC_SUCHT);
public static final List<Long> AGENCY_IDS_LIST = Collections.singletonList(AGENCY_ID);

Expand Down

0 comments on commit 7f44d8f

Please sign in to comment.