Skip to content

Commit

Permalink
feat: added topic slug to topic dto
Browse files Browse the repository at this point in the history
  • Loading branch information
web-mi committed Nov 7, 2023
1 parent c010df7 commit 03b67db
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/topicservice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ components:
type: string
example: "Topic name"
maxLength: 100
slug:
type: string
example: "topic_slug"
maxLength: 100
description:
type: string
example: "Description"
Expand Down Expand Up @@ -318,6 +322,10 @@ components:
type: object
additionalProperties:
type: string
slug:
type: string
example: "topic_slug"
maxLength: 100
description:
type: object
additionalProperties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public TopicDTO toDTO(final TopicEntity topic, final String lang) {
new TopicDTO()
.id(topic.getId())
.name(getTranslatedStringFromMap(topic.getName(), lang))
.slug(topic.getSlug())
.description(getTranslatedStringFromMap(topic.getDescription(), lang))
.status(topic.getStatus().name())
.fallbackAgencyId(topic.getFallbackAgencyId())
Expand Down Expand Up @@ -64,6 +65,7 @@ public TopicMultilingualDTO toMultilingualDTO(final TopicEntity topic) {
new TopicMultilingualDTO()
.id(topic.getId())
.name(convertMapFromJson(topic.getName()))
.slug(topic.getSlug())
.description(convertMapFromJson(topic.getDescription()))
.status(topic.getStatus().name())
.fallbackAgencyId(topic.getFallbackAgencyId())
Expand Down Expand Up @@ -93,6 +95,7 @@ public List<TopicDTO> toDTOList(final Collection<TopicEntity> topicEntities) {
public TopicEntity toEntity(final TopicMultilingualDTO topicDTO) {
final TopicEntity topicEntity = new TopicEntity();
topicEntity.setName(convertToJson(topicDTO.getName()));
topicEntity.setSlug(topicDTO.getSlug());
topicEntity.setStatus(TopicStatus.valueOf(topicDTO.getStatus().toUpperCase()));
topicEntity.setDescription(convertToJson(topicDTO.getDescription()));
topicEntity.setUpdateDate(LocalDateTime.now(ZoneOffset.UTC));
Expand All @@ -109,6 +112,7 @@ public TopicEntity toEntity(final TopicMultilingualDTO topicDTO) {

public TopicEntity toEntity(final TopicEntity targetEntity, final TopicMultilingualDTO topicDTO) {
targetEntity.setName(convertToJson(topicDTO.getName()));
targetEntity.setSlug(topicDTO.getSlug());
targetEntity.setStatus(TopicStatus.valueOf(topicDTO.getStatus()));
targetEntity.setDescription(convertToJson(topicDTO.getDescription()));
targetEntity.setInternalIdentifier(topicDTO.getInternalIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ public class TopicEntity implements TenantAware {

@Column(name = "titles_dropdown")
private String titlesDropdown;

@Column(name = "slug")
private String slug;
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void updateTopic_Should_returnStatusOk_When_calledWithValidCreateParamsAndValidA
new MultilingualTopicTestDataBuilder()
.topicDTO()
.withName("new name")
.withSlug("new_slug")
.withDescription("new desc")
.withInternalIdentifier("new ident")
.withStatus(TopicStatus.INACTIVE.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void toEntity_should_convertToEntityAndBackToMultilingualDTO() {
.status(TopicStatus.ACTIVE.toString())
.internalIdentifier("identifier")
.name(name)
.slug("slug")
.titles(
new TitlesDTO()._short("ts")._long("tl").registrationDropdown("td").welcome("tw"))
.description(description);
Expand All @@ -44,6 +45,7 @@ void toEntity_should_convertToEntityAndBackToMultilingualDTO() {
// then
final TopicDTO actual = topicConverter.toDTO(entity);
assertThat(actual.getName()).isEqualTo(topicDTO.getName().get("de"));
assertThat(actual.getSlug()).isEqualTo(topicDTO.getSlug());
assertThat(actual.getDescription()).isEqualTo(topicDTO.getDescription().get("de"));
}

Expand All @@ -58,6 +60,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier")
.name("{\"de\":\"name de\", \"en\":\"name en\"}")
.description("{\"de\":\"desc de\", \"en\":\"desc en\"}")
.slug("slug")
.titlesShort("ts")
.titlesLong("tl")
.titlesDropdown("td")
Expand All @@ -70,6 +73,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier 2")
.name("{\"de\":\"name 2 de\", \"en\":\"name 2 en\"}")
.description("{\"de\":\"desc 2 de\", \"en\":\"desc 2 en\"}")
.slug("slug")
.titlesShort("ts")
.titlesLong("tl")
.titlesDropdown("td")
Expand All @@ -83,6 +87,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.status(TopicStatus.ACTIVE.toString())
.internalIdentifier("identifier")
.name("name en")
.slug("slug")
.titles(titles)
.description("desc en");
final var topicDTO2 =
Expand All @@ -91,6 +96,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.status(TopicStatus.ACTIVE.toString())
.internalIdentifier("identifier 2")
.name("name 2 en")
.slug("slug")
.titles(titles)
.description("desc 2 en");

Expand All @@ -113,6 +119,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier")
.name("{\"de\":\"name de\", \"en\":\"name en\"}")
.description("{\"de\":\"desc de\", \"en\":\"desc en\"}")
.slug("slug")
.titlesShort("ts")
.titlesLong("tl")
.titlesDropdown("td")
Expand All @@ -125,6 +132,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier 2")
.name("{\"de\":\"name 2 de\", \"en\":\"name 2 en\"}")
.description("{\"de\":\"desc 2 de\", \"en\":\"desc 2 en\"}")
.slug("slug")
.titlesShort("ts")
.titlesLong("tl")
.titlesDropdown("td")
Expand All @@ -138,6 +146,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.status(TopicStatus.ACTIVE.toString())
.internalIdentifier("identifier")
.name("name de")
.slug("slug")
.titles(titles)
.description("desc de");
final var topicDTO2 =
Expand All @@ -146,6 +155,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.status(TopicStatus.ACTIVE.toString())
.internalIdentifier("identifier 2")
.name("name 2 de")
.slug("slug")
.titles(titles)
.description("desc 2 de");

Expand All @@ -168,6 +178,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier")
.name("{\"de\":\"name de\", \"en\":\"name en\"}")
.description("{\"de\":\"desc de\", \"en\":\"desc en\"}")
.slug("slug")
.titlesLong(titles.getLong())
.titlesShort(titles.getShort())
.titlesDropdown(titles.getRegistrationDropdown())
Expand All @@ -180,6 +191,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier 2")
.name("{\"de\":\"name 2 de\", \"en\":\"name 2 en\"}")
.description("{\"de\":\"desc 2 de\", \"en\":\"desc 2 en\"}")
.slug("slug")
.titlesLong(titles.getLong())
.titlesShort(titles.getShort())
.titlesWelcome(titles.getWelcome())
Expand All @@ -205,6 +217,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier")
.name(name1)
.description(description1)
.slug("slug")
.titles(titles);
final var topicDTO2 =
new TopicMultilingualDTO()
Expand All @@ -213,6 +226,7 @@ void toDTOList_Should_convertCollectionOfTopicEntitiesToListOfTopicDTOsWithCorre
.internalIdentifier("identifier 2")
.name(name2)
.description(description2)
.slug("slug")
.titles(titles);

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void topicGroupRepositoryReturnsSomeMeaningfulData() {
val te1 =
TopicEntity.builder()
.name("te1")
.slug("s1")
.createDate(now)
.updateDate(now)
.titlesDropdown("td")
Expand All @@ -56,6 +57,7 @@ void topicGroupRepositoryReturnsSomeMeaningfulData() {
val te2 =
TopicEntity.builder()
.name("te2")
.slug("s2")
.createDate(now)
.updateDate(now)
.titlesDropdown("td")
Expand Down Expand Up @@ -97,6 +99,7 @@ void deletingTopicGroupKeepsTopicsUntouched() {
val te1 =
TopicEntity.builder()
.name("te1")
.slug("s1")
.createDate(now)
.updateDate(now)
.titlesDropdown("td")
Expand All @@ -107,6 +110,7 @@ void deletingTopicGroupKeepsTopicsUntouched() {
val te2 =
TopicEntity.builder()
.name("te2")
.slug("s2")
.createDate(now)
.updateDate(now)
.titlesDropdown("td")
Expand All @@ -117,6 +121,7 @@ void deletingTopicGroupKeepsTopicsUntouched() {
val te3 =
TopicEntity.builder()
.name("te3")
.slug("s3")
.createDate(now)
.updateDate(now)
.titlesDropdown("td")
Expand All @@ -127,6 +132,7 @@ void deletingTopicGroupKeepsTopicsUntouched() {
val te4 =
TopicEntity.builder()
.name("te4")
.slug("s4")
.createDate(now)
.updateDate(now)
.titlesDropdown("td")
Expand Down Expand Up @@ -180,6 +186,7 @@ void deletingTopicGetsItRemovedFromGroup() {
val te1 =
TopicEntity.builder()
.name("te1")
.slug("s1")
.createDate(now)
.updateDate(now)
.titlesLong("long")
Expand All @@ -190,6 +197,7 @@ void deletingTopicGetsItRemovedFromGroup() {
val te2 =
TopicEntity.builder()
.name("te2")
.slug("s2")
.createDate(now)
.updateDate(now)
.titlesLong("long")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void save_Should_saveNewTopic() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.titlesLong("long")
.titlesShort("short")
Expand All @@ -78,6 +79,7 @@ void save_Should_saveNewTopic_withFallbackAgencyId() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.fallbackAgencyId(123)
.titlesLong("long")
Expand All @@ -100,6 +102,7 @@ void save_Should_saveNewTopic_withoutFallbackAgencyId() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.titlesLong("long")
.titlesShort("short")
Expand All @@ -125,6 +128,7 @@ void save_Should_saveNewTopic_withFallbackUrl() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.fallbackUrl(fallbackUrl)
.titlesLong("long")
Expand All @@ -147,6 +151,7 @@ void save_Should_saveNewTopic_withoutFallbackUrl() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.titlesLong("long")
.titlesShort("short")
Expand All @@ -172,6 +177,7 @@ void save_Should_saveNewTopic_withWelcomeMessage() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.welcomeMessage(welcomeMessage)
.titlesShort("short")
Expand All @@ -194,6 +200,7 @@ void save_Should_saveNewTopic_withoutWelcomeMessage() {
TopicEntity.builder()
.name(NEW_TOPIC_NAME)
.description("desc")
.slug("slug")
.createDate(LocalDateTime.now())
.titlesWelcome("welcome")
.titlesLong("long")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private static TopicEntity newTopicEntity(String te1, LocalDateTime now) {
.name(te1)
.createDate(now)
.updateDate(now)
.slug("slug")
.titlesDropdown("td")
.titlesWelcome("tw")
.titlesLong("tl")
Expand Down

0 comments on commit 03b67db

Please sign in to comment.