Browse Source

testmem

master
Krishna Nanda 4 years ago
parent
commit
2a2a1a7c90
18 changed files with 67 additions and 4 deletions
  1. BIN
      UB_UserServiceProxy/bin/.mvn/wrapper/MavenWrapperDownloader.class
  2. 6
      UB_UserServiceProxy/bin/pom.xml
  3. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/ServletInitializer.class
  4. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.class
  5. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/MemberUserController.class
  6. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/UserController.class
  7. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/MemberUser.class
  8. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/User.class
  9. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/UserLogin.class
  10. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.class
  11. BIN
      UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/UserRepository.class
  12. 6
      UB_UserServiceProxy/bin/src/main/resources/application.properties
  13. BIN
      UB_UserServiceProxy/bin/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.class
  14. 5
      UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/controller/MemberUserController.java
  15. 4
      UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.java
  16. 2
      UB_UserServiceProxy/src/main/resources/application.properties
  17. 47
      UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/MemberControllerTest.java
  18. 1
      UB_UserServiceProxy/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.java

BIN
UB_UserServiceProxy/bin/.mvn/wrapper/MavenWrapperDownloader.class

6
UB_UserServiceProxy/bin/pom.xml

@ -42,6 +42,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/ServletInitializer.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/MemberUserController.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/controller/UserController.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/MemberUser.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/User.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/model/UserLogin.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/MemberUserRepository.class

BIN
UB_UserServiceProxy/bin/src/main/java/com/example/urbanbazaar/repository/UserRepository.class

6
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

BIN
UB_UserServiceProxy/bin/src/test/java/com/example/urbanbazaar/controller/UserControllerTest.class

5
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<MemberUser> 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);

4
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<MemberUser, Integer> {
@Query(value="select * from members where members.UserId = ?1",nativeQuery=true)
public List<MemberUser> findByuserid(int userId);
public MemberUser findBymembername(String name);
}

2
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

47
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();
}
}

1
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;

Loading…
Cancel
Save