Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89916b0
commit 2189110
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/main/java/com/rimonmostafiz/elasticlight/core/Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.rimonmostafiz.elasticlight.core; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
/** | ||
* @author Rimon Mostafiz | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
public class Command { | ||
private Verb verb; | ||
private String path; | ||
private String body; | ||
private Head head; | ||
|
||
public Command() { | ||
this.path = ""; | ||
this.verb = Verb.GET; | ||
this.head = Head.JSON; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/rimonmostafiz/elasticlight/core/Head.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.rimonmostafiz.elasticlight.core; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
/** | ||
* @author Rimon Mostafiz | ||
*/ | ||
@AllArgsConstructor | ||
public enum Head { | ||
JSON("application/json"), | ||
ND_JSON("application/ndjson"); | ||
|
||
public String value; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/rimonmostafiz/elasticlight/core/Verb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.rimonmostafiz.elasticlight.core; | ||
|
||
import org.springframework.http.HttpMethod; | ||
|
||
/** | ||
* @author Rimon Mostafiz | ||
*/ | ||
public enum Verb { | ||
GET, POST, PUT, DELETE; | ||
|
||
public HttpMethod resolve() { | ||
return HttpMethod.resolve(this.name()); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/com/rimonmostafiz/elasticlight/core/CommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.rimonmostafiz.elasticlight.core; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
/** | ||
* @author Rimon Mostafiz | ||
*/ | ||
@SpringBootTest | ||
class CommandTest { | ||
|
||
private Command command; | ||
|
||
@BeforeEach | ||
public void before() { | ||
this.command = new Command(); | ||
} | ||
|
||
@Test | ||
public void defaultValue() { | ||
Assertions.assertNotNull(command, "command null"); | ||
|
||
Assertions.assertNotNull(this.command.getVerb(), "command.verb null"); | ||
Assertions.assertEquals(command.getVerb(), Verb.GET, "command.verb is not GET"); | ||
|
||
Assertions.assertNotNull(this.command.getPath(), "command.path null"); | ||
Assertions.assertEquals(this.command.getPath(), "", "command.path not empty"); | ||
|
||
Assertions.assertNull(this.command.getBody(), "command.body is not null"); | ||
|
||
Assertions.assertNotNull(this.command.getHead(), "command.head is null"); | ||
Assertions.assertEquals(this.command.getHead(), Head.JSON, "command.head is not JSON"); | ||
} | ||
} |