diff --git a/UB_UserServiceProxy/bin/.mvn/wrapper/MavenWrapperDownloader.class b/UB_UserServiceProxy/bin/.mvn/wrapper/MavenWrapperDownloader.class index 3075e87..860ca68 100644 Binary files a/UB_UserServiceProxy/bin/.mvn/wrapper/MavenWrapperDownloader.class and b/UB_UserServiceProxy/bin/.mvn/wrapper/MavenWrapperDownloader.class differ diff --git a/UB_UserServiceProxy/bin/pom.xml b/UB_UserServiceProxy/bin/pom.xml index 391d8d6..05708ba 100644 --- a/UB_UserServiceProxy/bin/pom.xml +++ b/UB_UserServiceProxy/bin/pom.xml @@ -42,6 +42,12 @@ spring-boot-starter-test test + + junit + junit + 4.12 + test + diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/ServletInitializer.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/ServletInitializer.class index d8a86f8..fe1424e 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/ServletInitializer.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/ServletInitializer.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.class index 93755c0..8bda0a7 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/MemberUserController.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/MemberUserController.class index 2d186bf..0f5a235 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/MemberUserController.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/MemberUserController.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/UserController.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/UserController.class index 5e4e783..f444e34 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/UserController.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/UserController.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/MemberUser.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/MemberUser.class index 873b82f..efb7eaf 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/MemberUser.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/MemberUser.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/User.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/User.class index 701a456..53cb447 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/User.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/User.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/UserLogin.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/UserLogin.class index 7194a74..cc2c9e9 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/UserLogin.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/UserLogin.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.class index bcc9d2d..d28516b 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.class differ diff --git a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/UserRepository.class b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/UserRepository.class index cce83b0..56e39d3 100644 Binary files a/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/UserRepository.class and b/UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/UserRepository.class differ diff --git a/UB_UserServiceProxy/bin/src/main/resources/application.properties b/UB_UserServiceProxy/bin/src/main/resources/application.properties index 83b07d7..51194ab 100644 --- a/UB_UserServiceProxy/bin/src/main/resources/application.properties +++ b/UB_UserServiceProxy/bin/src/main/resources/application.properties @@ -1,10 +1,10 @@ -server.port=8001 +server.port=8500 -spring.datasource.url=jdbc:mysql://10.3.117.7:3306/grocery_db?createDatabaseIfNotExist=true +spring.datasource.url=jdbc:mysql://10.3.117.22:3306/grocery_db?createDatabaseIfNotExist=true spring.datasource.username=testuser spring.datasource.password=Password123 -server.servlet.context-path=/user +server.servlet.context-path=/users spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect spring.jpa.hibernate.ddl-auto=update diff --git a/UB_UserServiceProxy/bin/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.class b/UB_UserServiceProxy/bin/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.class new file mode 100644 index 0000000..84a845c Binary files /dev/null and b/UB_UserServiceProxy/bin/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.class differ diff --git a/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/controller/MemberUserController.java b/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/controller/MemberUserController.java index 8a7841c..31bedd1 100644 --- a/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/controller/MemberUserController.java +++ b/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/controller/MemberUserController.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import com.example.urbanbazaar.model.MemberUser; +import com.example.urbanbazaar.model.User; import com.example.urbanbazaar.repository.MemberUserRepository; //@CrossOrigin(origins = "http://localhost:4405") @CrossOrigin(origins = "http://localhost:63871") @@ -41,6 +42,10 @@ public class MemberUserController { public List showMembersByUser(@PathVariable int userId) { return repo.findByuserid(userId); } + @GetMapping("/findMemberByName/{name}") + public MemberUser findMemberByName(@PathVariable String name) { + return repo.findBymembername(name); + } @DeleteMapping("/deleteMember/{memberid}") public void deleteMemberById(@PathVariable int memberid ) { repo.deleteById(memberid); diff --git a/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.java b/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.java index 66cc203..e8815c7 100644 --- a/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.java +++ b/UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.java @@ -6,8 +6,12 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import com.example.urbanbazaar.model.MemberUser; +import com.example.urbanbazaar.model.User; public interface MemberUserRepository extends JpaRepository { @Query(value="select * from members where members.UserId = ?1",nativeQuery=true) public List findByuserid(int userId); + + + public MemberUser findBymembername(String name); } diff --git a/UB_UserServiceProxy/src/main/resources/application.properties b/UB_UserServiceProxy/src/main/resources/application.properties index 51194ab..6b54763 100644 --- a/UB_UserServiceProxy/src/main/resources/application.properties +++ b/UB_UserServiceProxy/src/main/resources/application.properties @@ -1,6 +1,6 @@ server.port=8500 -spring.datasource.url=jdbc:mysql://10.3.117.22:3306/grocery_db?createDatabaseIfNotExist=true +spring.datasource.url=jdbc:mysql://10.3.117.21:3306/grocery_db?createDatabaseIfNotExist=true spring.datasource.username=testuser spring.datasource.password=Password123 diff --git a/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/MemberControllerTest.java b/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/MemberControllerTest.java new file mode 100644 index 0000000..3adf033 --- /dev/null +++ b/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/MemberControllerTest.java @@ -0,0 +1,47 @@ +package com.example.urbanbazaar.controller; + +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; + +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import com.example.urbanbazaar.UbUserServiceProxyApplication; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = UbUserServiceProxyApplication.class) +@SpringBootTest +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class MemberControllerTest { + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext wac; + + @Before + public void setUp() { + this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); + } + + @Test + public void shouldFetchAllMembers() throws Exception { + this.mockMvc.perform(MockMvcRequestBuilders.get("/users/showAllMembers") + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(jsonPath("$", hasSize(4))) + .andReturn(); + } +} diff --git a/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.java b/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.java index 267055b..31d69b3 100644 --- a/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.java +++ b/UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.java @@ -1,6 +1,7 @@ package com.example.urbanbazaar.controller; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; + import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;