diff --git a/MyMentorProject/.idea/.gitignore b/MyMentorProject/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/MyMentorProject/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/MyMentorProject/.idea/MyMentorProject.iml b/MyMentorProject/.idea/MyMentorProject.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/MyMentorProject/.idea/MyMentorProject.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/compiler.xml b/MyMentorProject/.idea/compiler.xml new file mode 100644 index 0000000..3b86bb9 --- /dev/null +++ b/MyMentorProject/.idea/compiler.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/dbnavigator.xml b/MyMentorProject/.idea/dbnavigator.xml new file mode 100644 index 0000000..4c97bdf --- /dev/null +++ b/MyMentorProject/.idea/dbnavigator.xml @@ -0,0 +1,461 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/encodings.xml b/MyMentorProject/.idea/encodings.xml new file mode 100644 index 0000000..63e9001 --- /dev/null +++ b/MyMentorProject/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/jarRepositories.xml b/MyMentorProject/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/MyMentorProject/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/jpa-buddy.xml b/MyMentorProject/.idea/jpa-buddy.xml new file mode 100644 index 0000000..d08f400 --- /dev/null +++ b/MyMentorProject/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/misc.xml b/MyMentorProject/.idea/misc.xml new file mode 100644 index 0000000..abe2ade --- /dev/null +++ b/MyMentorProject/.idea/misc.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/uiDesigner.xml b/MyMentorProject/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/MyMentorProject/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.idea/vcs.xml b/MyMentorProject/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/MyMentorProject/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MyMentorProject/.mvn/wrapper/maven-wrapper.jar b/MyMentorProject/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..c1dd12f Binary files /dev/null and b/MyMentorProject/.mvn/wrapper/maven-wrapper.jar differ diff --git a/MyMentorProject/.mvn/wrapper/maven-wrapper.properties b/MyMentorProject/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..b7cb93e --- /dev/null +++ b/MyMentorProject/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/MyMentorProject/pom.xml b/MyMentorProject/pom.xml new file mode 100644 index 0000000..5a57f84 --- /dev/null +++ b/MyMentorProject/pom.xml @@ -0,0 +1,58 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.7 + + + com.Deny + MyMentorProject + 0.0.1-SNAPSHOT + MyMentorProject + Demo project for Spring Boot + + 11 + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + log4j + log4j + 1.2.17 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/MyMentorProject/src/main/java/com/Deny/MyMentorProject/Controllers/UserMainController.java b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/Controllers/UserMainController.java new file mode 100644 index 0000000..2b965c9 --- /dev/null +++ b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/Controllers/UserMainController.java @@ -0,0 +1,39 @@ +package com.Deny.MyMentorProject.Controllers; + +import com.Deny.MyMentorProject.Services.UserService; +import com.Deny.MyMentorProject.User.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class UserMainController { + + @Autowired +UserService userService; + + public UserMainController(UserService userService) { + this.userService = userService; + } + + @GetMapping + public String helloMessage() { + + return userService. helloMessage(); + } + + @GetMapping("/greetUser") + public String helloUser() { + + return "hello " + userService.helloUser(); + } + @PostMapping("greetings" ) + public String messageToReturn(@RequestBody String requestMessage ){ + System.out.println("requestMessage = " + requestMessage); + return userService.messageToReTurn( requestMessage); + + } +} \ No newline at end of file diff --git a/MyMentorProject/src/main/java/com/Deny/MyMentorProject/MyMentorProjectApplication.java b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/MyMentorProjectApplication.java new file mode 100644 index 0000000..91a4e83 --- /dev/null +++ b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/MyMentorProjectApplication.java @@ -0,0 +1,13 @@ +package com.Deny.MyMentorProject; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MyMentorProjectApplication { + + public static void main(String[] args) { + SpringApplication.run(MyMentorProjectApplication.class, args); + } + +} diff --git a/MyMentorProject/src/main/java/com/Deny/MyMentorProject/Services/UserService.java b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/Services/UserService.java new file mode 100644 index 0000000..1c35ce9 --- /dev/null +++ b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/Services/UserService.java @@ -0,0 +1,50 @@ +package com.Deny.MyMentorProject.Services; + +import com.Deny.MyMentorProject.User.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserService { + + User user; + + + public UserService(User user) { this.user = user; + } + + + public String helloMessage() { + return "Hello My Friend !";} + + public String helloUser() { + user.setName("Joe"); + return "hello " + user.getName(); + } + public String messageToReTurn(String messagerequest) { + + String reply = ""; + + if (messagerequest ==""){ + reply = "hello " + user.getName(); + } + else if (messagerequest ==" happy Message") { + reply = "Hey " + user.getName() + " nice to see you here !!"; + } + else if (messagerequest =="welcome me") { + + reply = user.getName() +" welcome back !!"; + } else if (messagerequest=="bye message") { + reply= "Have a splendid day "+user.getName(); + + } + System.out.println("messagerequest = " + messagerequest); + return reply; + } + + + } + + + + diff --git a/MyMentorProject/src/main/java/com/Deny/MyMentorProject/User/User.java b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/User/User.java new file mode 100644 index 0000000..af11955 --- /dev/null +++ b/MyMentorProject/src/main/java/com/Deny/MyMentorProject/User/User.java @@ -0,0 +1,49 @@ +package com.Deny.MyMentorProject.User; + + +import org.springframework.stereotype.Service; + +@Service +public class User { + + private Long id; + + public void setName(String name) { + this.name = name; + } + + private String name; + + + public User() { + } + + public User(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } + + + + +} diff --git a/MyMentorProject/src/main/resources/application.properties b/MyMentorProject/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/MyMentorProject/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/MyMentorProject/src/test/java/com/Deny/MyMentorProject/MyMentorProjectApplicationTests.java b/MyMentorProject/src/test/java/com/Deny/MyMentorProject/MyMentorProjectApplicationTests.java new file mode 100644 index 0000000..8d124d7 --- /dev/null +++ b/MyMentorProject/src/test/java/com/Deny/MyMentorProject/MyMentorProjectApplicationTests.java @@ -0,0 +1,13 @@ +package com.Deny.MyMentorProject; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class MyMentorProjectApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/MyMentorProject/src/test/java/com/Deny/MyMentorProject/Services/UserServiceTest.java b/MyMentorProject/src/test/java/com/Deny/MyMentorProject/Services/UserServiceTest.java new file mode 100644 index 0000000..71306e1 --- /dev/null +++ b/MyMentorProject/src/test/java/com/Deny/MyMentorProject/Services/UserServiceTest.java @@ -0,0 +1,43 @@ +package com.Deny.MyMentorProject.Services; + +import com.Deny.MyMentorProject.User.User; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + +class UserServiceTest { + private UserService userServiceUnderTest; + private User user; + @BeforeEach + void setUp() { + userServiceUnderTest=new UserService(user); + } +@Test + void shouldReturnStringHellowWorld(){ +//THIS IS FOR J-UNIT 5 JUPITER + //given + String hellow="Hello My Friend !"; + //when + String stringValidity =userServiceUnderTest.helloMessage(); + //then + assertEquals(hellow,stringValidity); + + } + @Test + void shouldReturnStringHellowWorldPlusUserName(){ + user.setName("Joe"); + //GIVEN + String message= "hello "+ user.getName(); + //WHEN + String stringValidityTwo =userServiceUnderTest.helloUser(); + //THEN + assertEquals(message,stringValidityTwo); + + + } + + + +} \ No newline at end of file diff --git a/MyMentorProject/target/classes/application.properties b/MyMentorProject/target/classes/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/MyMentorProject/target/classes/application.properties @@ -0,0 +1 @@ + diff --git a/MyMentorProject/target/classes/com/Deny/MyMentorProject/Controllers/UserMainController.class b/MyMentorProject/target/classes/com/Deny/MyMentorProject/Controllers/UserMainController.class new file mode 100644 index 0000000..1b2fee0 Binary files /dev/null and b/MyMentorProject/target/classes/com/Deny/MyMentorProject/Controllers/UserMainController.class differ diff --git a/MyMentorProject/target/classes/com/Deny/MyMentorProject/MyMentorProjectApplication.class b/MyMentorProject/target/classes/com/Deny/MyMentorProject/MyMentorProjectApplication.class new file mode 100644 index 0000000..61e24cb Binary files /dev/null and b/MyMentorProject/target/classes/com/Deny/MyMentorProject/MyMentorProjectApplication.class differ diff --git a/MyMentorProject/target/classes/com/Deny/MyMentorProject/Services/UserService.class b/MyMentorProject/target/classes/com/Deny/MyMentorProject/Services/UserService.class new file mode 100644 index 0000000..075d4b5 Binary files /dev/null and b/MyMentorProject/target/classes/com/Deny/MyMentorProject/Services/UserService.class differ diff --git a/MyMentorProject/target/classes/com/Deny/MyMentorProject/User/User.class b/MyMentorProject/target/classes/com/Deny/MyMentorProject/User/User.class new file mode 100644 index 0000000..bcad6b0 Binary files /dev/null and b/MyMentorProject/target/classes/com/Deny/MyMentorProject/User/User.class differ diff --git a/MyMentorProject/target/test-classes/com/Deny/MyMentorProject/MyMentorProjectApplicationTests.class b/MyMentorProject/target/test-classes/com/Deny/MyMentorProject/MyMentorProjectApplicationTests.class new file mode 100644 index 0000000..0d46f28 Binary files /dev/null and b/MyMentorProject/target/test-classes/com/Deny/MyMentorProject/MyMentorProjectApplicationTests.class differ diff --git a/MyMentorProject/target/test-classes/com/Deny/MyMentorProject/Services/UserServiceTest.class b/MyMentorProject/target/test-classes/com/Deny/MyMentorProject/Services/UserServiceTest.class new file mode 100644 index 0000000..d20c476 Binary files /dev/null and b/MyMentorProject/target/test-classes/com/Deny/MyMentorProject/Services/UserServiceTest.class differ