@Test public void test_shouldReturn_tenantCode_error() throws Exception{ City city = City.builder() .name("testname") .localName("testlocalname") .districtCode("districtcode") .districtName("testdistrictname") .regionName("testregionname") .longitude(35.456) .latitude(75.443) .ulbGrade("testCorporation") .shapeFileLocation("testshapeFileLocation") .captcha("testcaptcha") .build(); Tenant tenant = Tenant.builder() .description("testdescription") .logoId("testlogoId") .imageId("testimageId") .domainUrl("testdomainUrl") .type("CITY") .twitterUrl("testtwitterUrl") .facebookUrl("testfaceBookUrl") .emailId("testemail") .address("testaddress") .contactNumber("contactNumber") .helpLineNumber("helpLineNumber") .city(city) .build(); when(tenantService.updateTenant(any(Tenant.class))).thenThrow(new InvalidTenantDetailsException(tenant)); mockMvc.perform(post("/v1/tenant/_update") .contentType(MediaType.APPLICATION_JSON) .content(new Resources().getFileContents("tenantUpdateRequest.json"))) .andExpect(status().isBadRequest()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(content().json(new Resources().getFileContents("tenantCodeErrorResponse.json"))); }
@PostMapping(value = "_update") public TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .updateTenant(updateTenantRequest.getTenant().toDomain()); return new TenantResponse(getResponseInfo(updateTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); }
TenantController { @PostMapping(value = "_update") public TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .updateTenant(updateTenantRequest.getTenant().toDomain()); return new TenantResponse(getResponseInfo(updateTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); } }
TenantController { @PostMapping(value = "_update") public TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .updateTenant(updateTenantRequest.getTenant().toDomain()); return new TenantResponse(getResponseInfo(updateTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); } @Autowired  TenantController(TenantService tenantService); }
TenantController { @PostMapping(value = "_update") public TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .updateTenant(updateTenantRequest.getTenant().toDomain()); return new TenantResponse(getResponseInfo(updateTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); } @Autowired  TenantController(TenantService tenantService); @PostMapping(value = "_search") SearchTenantResponse search(@RequestParam(value = "code", required = false) List<String> code,
			@RequestBody SearchTenantRequest searchTenantRequest); @PostMapping(value = "_create") CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest); @PostMapping(value = "_update") TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest); ResponseInfo getResponseInfo(RequestInfo requestInfo); }
TenantController { @PostMapping(value = "_update") public TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .updateTenant(updateTenantRequest.getTenant().toDomain()); return new TenantResponse(getResponseInfo(updateTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); } @Autowired  TenantController(TenantService tenantService); @PostMapping(value = "_search") SearchTenantResponse search(@RequestParam(value = "code", required = false) List<String> code,
			@RequestBody SearchTenantRequest searchTenantRequest); @PostMapping(value = "_create") CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest); @PostMapping(value = "_update") TenantResponse updateTenant(@RequestBody TenantRequest updateTenantRequest); ResponseInfo getResponseInfo(RequestInfo requestInfo);  }