CensusEntryCommandConverterTest.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) Andrew Grant of Carrick Software 18/03/2025, 10:22. All rights reserved.
  3. *
  4. */
  5. package scot.carricksoftware.grants.converters.census;
  6. import org.junit.jupiter.api.BeforeEach;
  7. import org.junit.jupiter.api.Test;
  8. import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
  9. import scot.carricksoftware.grants.commands.census.CensusEntryCommandImpl;
  10. import scot.carricksoftware.grants.domains.census.Census;
  11. import scot.carricksoftware.grants.domains.census.CensusEntry;
  12. import scot.carricksoftware.grants.domains.people.Person;
  13. import scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
  14. import scot.carricksoftware.grants.enums.censusentry.CensusEntryGaelic;
  15. import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
  16. import static org.junit.jupiter.api.Assertions.assertEquals;
  17. import static scot.carricksoftware.grants.GenerateCensusEntryRandomEnums.*;
  18. import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
  19. import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
  20. import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
  21. import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
  22. class CensusEntryCommandConverterTest {
  23. private CensusEntryCommandConverter converter;
  24. @BeforeEach
  25. void setUp() {
  26. converter = new CensusEntryCommandConverterImpl();
  27. }
  28. @Test
  29. void convertTest() {
  30. Long id = GetRandomLong();
  31. String name = GetRandomString();
  32. CensusEntryRelationship relationship = GetRandomCensusEntryRelationship();
  33. CensusEntryCondition condition = GetRandomCensusEntryCondition();
  34. CensusEntryGaelic gaelic = GetRandomCensusEntryGaelic();
  35. CensusEntryCommand source = new CensusEntryCommandImpl();
  36. Census census = GetRandomCensus();
  37. Person person = GetRandomPerson();
  38. source.setId(id);
  39. source.setName(name);
  40. source.setCensus(census);
  41. source.setPerson(person);
  42. source.setRelationship(relationship);
  43. source.setCondition(condition);
  44. source.setGaelic(gaelic);
  45. CensusEntry target = converter.convert(source);
  46. assert target != null;
  47. assertEquals(id, target.getId());
  48. assertEquals(name, target.getName());
  49. assertEquals(census, target.getCensus());
  50. assertEquals(person, target.getPerson());
  51. assertEquals(relationship, target.getRelationship());
  52. assertEquals(condition, target.getCondition());
  53. assertEquals(gaelic, target.getGaelic());
  54. }
  55. }