Skip to content

Commit

Permalink
Review comments addressed
Browse files Browse the repository at this point in the history
Improvements after review comments incorporated
  • Loading branch information
goelsonali committed Aug 9, 2024
1 parent f538bea commit 72825f0
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 26 deletions.
8 changes: 0 additions & 8 deletions config/pmd/custom-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,4 @@
</properties>
</rule>
<!-- END CODE DOCUMENTATION -->

<!-- DESIGN -->
<rule ref="rulesets/design.xml/ExcessiveParameterList">
<properties>
<property name="maxParameters" value="10"/>
</properties>
</rule>
<!-- END CODE DESIGN -->
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ProgrammeController(final ProgrammeService programmeService) {
@Operation(summary = "API to retrieve programme page")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<ProgrammePage> getProgramme(
@RequestParam(required = false, name = "type") final ProgramType programmeType) {
@RequestParam(name = "type") final ProgramType programmeType) {
return ResponseEntity.ok(service.getProgramme(programmeType));
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/wcc/platform/domain/platform/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.Builder;
import lombok.Data;

/** Event class with all the relevant attributes for an event. */
@Data
@Builder
public class Event {
Expand All @@ -26,6 +27,8 @@ public class Event {
private SimpleLink eventLink;
private List<EventResource> eventResources;

/** Event builder. */
@SuppressWarnings("PMD.ExcessiveParameterList")
public Event(
final UUID id,
final String title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
import lombok.Builder;
import lombok.Data;

/** EventSection representing list of events {@link Event}. */
@Data
@Builder
public class EventSection {
private String title;
private SimpleLink link;
private List<Event> events;

/**
* Builder for the EventSection.
*
* @param title like - "Upcoming Events" or "Past Events"
* @param link link to the Events page
* @param events list of events to show
*/
public EventSection(final String title, final SimpleLink link, final List<Event> events) {
this.title = title;
this.link = link;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/wcc/platform/domain/platform/Programme.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Builder;
import lombok.Data;

/** Programme class representing the structure of any programme section of a programme page. */
@Data
@Builder
public class Programme {
Expand All @@ -14,6 +15,13 @@ public class Programme {

private Card card;

/**
* Programme Builder.
*
* @param title like - heading of the programme
* @param description details co-relating the title
* @param card if any details to be represented in a card
*/
public Programme(final String title, final String description, final Card card) {
this.title = title;
this.description = description;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/wcc/platform/service/CmsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.stereotype.Service;

/** CMS service responsible for simple pages. */
@SuppressWarnings("PMD.TooManyStaticImports")
@Service
public class CmsService {
private final ObjectMapper objectMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.wcc.platform.domain.platform;

import static com.wcc.platform.factories.SetupEventFactories.createEventSection;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.wcc.platform.domain.cms.attributes.ProgramType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/** Test class for the class {@link EventSection}. */
class EventSectionTest {

EventSection testEventSection;

@BeforeEach
void setup() {
testEventSection = createEventSection();
}

@Test
void testEquals() {
assertEquals(testEventSection, createEventSection(ProgramType.BOOK_CLUB));
}

@Test
void testNotEquals() {
assertNotEquals(testEventSection, createEventSection(ProgramType.TECH_TALK));
}

@Test
void testHashCode() {
assertEquals(testEventSection.hashCode(), createEventSection(ProgramType.BOOK_CLUB).hashCode());
}

@Test
void testHashCodeNotEquals() {
assertNotEquals(
testEventSection.hashCode(), createEventSection(ProgramType.TECH_TALK).hashCode());
}

@Test
void testToString() {
assertTrue(testEventSection.toString().contains(ProgramType.BOOK_CLUB.toString()));
}
}
50 changes: 50 additions & 0 deletions src/test/java/com/wcc/platform/domain/platform/EventTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.wcc.platform.domain.platform;

import static com.wcc.platform.factories.SetupEventFactories.createEventTest;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.wcc.platform.domain.cms.attributes.ProgramType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/** Test class for the class {@link Event}. */
class EventTest {

Event testEvent;

@BeforeEach
void setup() {
testEvent = createEventTest();
}

@Test
void testEqual() {
assertEquals(testEvent, createEventTest(ProgramType.BOOK_CLUB));
}

@Test
void testNotEqual() {
assertNotEquals(testEvent, createEventTest(ProgramType.TECH_TALK));
assertNotEquals(testEvent, createEventTest(ProgramType.WRITING_CLUB));
assertNotEquals(
createEventTest(ProgramType.WRITING_CLUB), createEventTest(ProgramType.TECH_TALK));
}

@Test
void testHashCode() {
assertEquals(testEvent.hashCode(), createEventTest(ProgramType.BOOK_CLUB).hashCode());
}

@Test
void testHashCodeNotEquals() {
assertNotEquals(testEvent.hashCode(), createEventTest(ProgramType.WRITING_CLUB).hashCode());
}

@Test
void testToString() {
assertTrue(testEvent.toString().contains(ProgramType.BOOK_CLUB.toString()));
assertTrue(testEvent.toString().contains(ProgramType.BOOK_CLUB.toString()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/** Test for class {@link Member} */
class MemberTest {

private Member member;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ProgrammeTest {
/** Test class for {@link Programme}. */
class ProgrammeTest {

Programme testProgramme;

Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/wcc/platform/factories/SetupEventFactories.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.wcc.platform.domain.cms.attributes.SimpleLink;
import com.wcc.platform.domain.cms.pages.EventsPage;
import com.wcc.platform.domain.platform.Event;
import com.wcc.platform.domain.platform.EventSection;
import com.wcc.platform.utils.FileUtil;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -51,4 +52,30 @@ public static EventsPage createEventPageTest(final List<Event> events) {
var hero = new HeroSection("title", "event description", createImageTest());
return new EventsPage(events, hero, createContactTest());
}

/**
* Create an EventSection object with test data.
*
* @return EventSection object
*/
public static EventSection createEventSection() {
return EventSection.builder()
.title("Upcoming Events")
.link(new SimpleLink("view events", "/events"))
.events(Collections.singletonList(createEventTest()))
.build();
}

/**
* Create an EventSection object with test data.
*
* @return EventSection object
*/
public static EventSection createEventSection(final ProgramType programType) {
return EventSection.builder()
.title("Upcoming Events")
.link(new SimpleLink("view events", "/events"))
.events(Collections.singletonList(createEventTest(programType)))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.wcc.platform.factories;

import static com.wcc.platform.factories.SetupEventFactories.createEventTest;
import static com.wcc.platform.factories.SetupEventFactories.createEventSection;
import static com.wcc.platform.factories.SetupFactories.OBJECT_MAPPER;
import static com.wcc.platform.factories.SetupFactories.createContactTest;
import static com.wcc.platform.factories.SetupFactories.createPageTest;
Expand All @@ -10,7 +10,6 @@
import com.wcc.platform.domain.cms.attributes.ProgramType;
import com.wcc.platform.domain.cms.attributes.SimpleLink;
import com.wcc.platform.domain.cms.pages.programme.ProgrammePage;
import com.wcc.platform.domain.platform.EventSection;
import com.wcc.platform.domain.platform.Programme;
import com.wcc.platform.utils.FileUtil;
import java.util.Collections;
Expand Down Expand Up @@ -84,17 +83,4 @@ public static Programme createProgrammeWithoutCard() {
.description("Every month we vote we read a book this is current month book.")
.build();
}

/**
* Create an EventSection object with test data.
*
* @return EventSection object
*/
public static EventSection createEventSection() {
return EventSection.builder()
.title("Upcoming Events")
.link(new SimpleLink("view events", "/events"))
.events(Collections.singletonList(createEventTest()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.mockito.Mockito;

/** Test class for ProgrammeService. */
public class ProgrammeServiceTest {
class ProgrammeServiceTest {
private ObjectMapper objectMapper;
private ProgrammeService service;

Expand Down

0 comments on commit 72825f0

Please sign in to comment.