@Test public void test_should_return_400_when_duplicate_tenant_code_exception() throws Exception { Tenant tenant = Tenant.builder() .code("AP.KURNOOL") .name("kurnool") .description("description") .logoId("logoId") .imageId("imageId") .domainUrl("domainUrl") .type("CITY") .twitterUrl("twitterUrl") .facebookUrl("faceBookUrl") .emailId("email") .address("address") .contactNumber("contactNumber") .helpLineNumber("helpLineNumber") .city(null) .build(); when(tenantService.createTenant(any(Tenant.class))).thenThrow(new DuplicateTenantCodeException(tenant)); mockMvc.perform(post("/v1/tenant/_create") .contentType(MediaType.APPLICATION_JSON) .content(new Resources().getFileContents("tenantCreateRequest.json"))) .andExpect(status().isBadRequest()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(content().json(new Resources().getFileContents("duplicateTenantCodeErrorResponse.json"))); }
@PostMapping(value = "_create") public CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .createTenant(createTenantRequest.getTenant().toDomain()); return new CreateTenantResponse(getResponseInfo(createTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); }
TenantController { @PostMapping(value = "_create") public CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .createTenant(createTenantRequest.getTenant().toDomain()); return new CreateTenantResponse(getResponseInfo(createTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); } }
TenantController { @PostMapping(value = "_create") public CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .createTenant(createTenantRequest.getTenant().toDomain()); return new CreateTenantResponse(getResponseInfo(createTenantRequest.getRequestInfo()), new Tenant(tenant, new City(tenant.getCity()))); } @Autowired  TenantController(TenantService tenantService); }
TenantController { @PostMapping(value = "_create") public CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .createTenant(createTenantRequest.getTenant().toDomain()); return new CreateTenantResponse(getResponseInfo(createTenantRequest.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 = "_create") public CreateTenantResponse createTenant(@RequestBody CreateTenantRequest createTenantRequest) { org.egov.tenant.domain.model.Tenant tenant = tenantService .createTenant(createTenantRequest.getTenant().toDomain()); return new CreateTenantResponse(getResponseInfo(createTenantRequest.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);  }