BAEL-6207 (#13557)
* BAEL-6207 IDD * Update pom.xml * Rename HelpRequestServiceTest.java to HelpRequestServiceUnitTest.java * Update HelpRequestServiceUnitTest.java
This commit is contained in:
parent
da08a21266
commit
24d57f0ab6
|
@ -0,0 +1 @@
|
|||
### Relevant Articles:
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>idd</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>idd</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>patterns-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
public class CreateHelpRequestDTO {
|
||||
|
||||
private final HelpRequestStatus status;
|
||||
|
||||
public CreateHelpRequestDTO(HelpRequestStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public HelpRequestStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
public class HelpRequestDTO {
|
||||
private HelpRequestStatus status;
|
||||
|
||||
public HelpRequestStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public HelpRequestDTO(HelpRequestStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HelpRequestService {
|
||||
HelpRequestDTO createHelpRequest(CreateHelpRequestDTO createHelpRequestDTO);
|
||||
|
||||
List<HelpRequestDTO> findAllByStatus(HelpRequestStatus status);
|
||||
|
||||
HelpRequestDTO updateHelpRequest(UpdateHelpRequestDTO updateHelpRequestDTO);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HelpRequestServiceImpl implements HelpRequestService {
|
||||
|
||||
@Override
|
||||
public HelpRequestDTO createHelpRequest(CreateHelpRequestDTO createHelpRequestDTO) {
|
||||
// here goes the implementation
|
||||
return new HelpRequestDTO(createHelpRequestDTO.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HelpRequestDTO> findAllByStatus(HelpRequestStatus status) {
|
||||
// here goes the implementation
|
||||
return List.of(new HelpRequestDTO(status), new HelpRequestDTO(status));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HelpRequestDTO updateHelpRequest(UpdateHelpRequestDTO updateHelpRequestDTO) {
|
||||
// here goes the implementation
|
||||
return new HelpRequestDTO(updateHelpRequestDTO.getStatus());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
public enum HelpRequestStatus {
|
||||
OPEN, IN_PROGRESS, CLOSED
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
public class UpdateHelpRequestDTO {
|
||||
|
||||
private final HelpRequestStatus status;
|
||||
|
||||
public UpdateHelpRequestDTO(HelpRequestStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public HelpRequestStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.baeldung.idd;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HelpRequestServiceUnitTest {
|
||||
|
||||
HelpRequestService testHelpRequestService = new HelpRequestService() {
|
||||
@Override
|
||||
public HelpRequestDTO createHelpRequest(CreateHelpRequestDTO createHelpRequestDTO) {
|
||||
return new HelpRequestDTO(HelpRequestStatus.OPEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HelpRequestDTO> findAllByStatus(HelpRequestStatus status) {
|
||||
return List.of(new HelpRequestDTO(HelpRequestStatus.OPEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HelpRequestDTO updateHelpRequest(UpdateHelpRequestDTO updateHelpRequestDTO) {
|
||||
return new HelpRequestDTO(HelpRequestStatus.OPEN);
|
||||
}
|
||||
};
|
||||
|
||||
@Test
|
||||
public void givenHelpRequest_whenCreateHelpRequest_thenHelpRequestIsCreated() {
|
||||
// given
|
||||
CreateHelpRequestDTO createHelpRequestDTO = new CreateHelpRequestDTO(HelpRequestStatus.OPEN);
|
||||
|
||||
// when
|
||||
HelpRequestDTO helpRequestDTO = testHelpRequestService.createHelpRequest(createHelpRequestDTO);
|
||||
|
||||
// then
|
||||
Assertions.assertThat(helpRequestDTO).isNotNull();
|
||||
Assertions.assertThat(helpRequestDTO.getStatus()).isEqualTo(HelpRequestStatus.OPEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHelpRequestList_whenFindAllByStatus_shouldContainOnlyStatus() {
|
||||
HelpRequestService helpRequestService = new HelpRequestServiceImpl();
|
||||
List<HelpRequestDTO> allByStatusOpen = helpRequestService.findAllByStatus(HelpRequestStatus.OPEN);
|
||||
Assertions.assertThat(allByStatusOpen).extracting(HelpRequestDTO::getStatus).containsOnly(HelpRequestStatus.OPEN);
|
||||
}
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@
|
|||
<module>clean-architecture</module>
|
||||
<module>enterprise-patterns</module>
|
||||
<module>coupling</module>
|
||||
<module>idd</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -71,4 +72,4 @@
|
|||
<jetty-maven-plugin.version>9.4.0.v20161208</jetty-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue