Skip to content

Commit

Permalink
GRAD2-2973 - Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kamal-mohammed committed Nov 13, 2024
1 parent e8c2e85 commit 2aafe04
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CodeController(CodeService codeService, GradValidation validation, Respon
@Operation(summary = "Reload School Category Codes in the cache", description = "Reload School Category Codes in the cache", tags = {"Cache"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "422", description = "UNPROCESSABLE CONTENT")})
public ResponseEntity reloadSchoolCategoryCodesIntoCache() {
public ResponseEntity<String> reloadSchoolCategoryCodesIntoCache() {
log.debug("reloadSchoolCategoryCodesIntoCache : ");
try {
codeService.initializeSchoolCategoryCodeCache(true);
Expand All @@ -59,7 +59,7 @@ public ResponseEntity reloadSchoolCategoryCodesIntoCache() {
@Operation(summary = "Reload School Funding Group Codes in the cache", description = "Reload School Funding Group Codes in the cache", tags = {"Cache"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "422", description = "UNPROCESSABLE CONTENT")})
public ResponseEntity reloadSchoolFundingGroupCodesIntoCache() {
public ResponseEntity<String> reloadSchoolFundingGroupCodesIntoCache() {
log.debug("reloadSchoolFundingGroupCodesIntoCache : ");
try {
codeService.initializeSchoolFundingGroupCodeCache(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public DistrictController(DistrictService districtService, GradValidation valida
@Operation(summary = "Reload Districts in the cache", description = "Reload Districts in the cache", tags = {"Cache"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "422", description = "UNPROCESSABLE CONTENT")})
public ResponseEntity reloadDistrictsIntoCache() {
public ResponseEntity<String> reloadDistrictsIntoCache() {
log.debug("reloadDistrictsIntoCache : ");
try {
districtService.initializeDistrictCache(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public SchoolController(SchoolService schoolService, GradValidation validation,
@Operation(summary = "Reload Schools in the cache", description = "Reload Schools in the cache", tags = {"Cache"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "422", description = "UNPROCESSABLE CONTENT")})
public ResponseEntity reloadSchoolsIntoCache() {
public ResponseEntity<String> reloadSchoolsIntoCache() {
log.debug("reloadSchoolsIntoCache : ");
try {
schoolService.initializeSchoolCache(true);
Expand Down Expand Up @@ -85,7 +85,7 @@ public ResponseEntity<School> getSchoolBySchoolId(@PathVariable UUID schoolId) {
@Operation(summary = "Reload School Details in the cache", description = "Reload School Details in the cache", tags = {"Cache"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "422", description = "UNPROCESSABLE CONTENT")})
public ResponseEntity reloadSchoolDetailsIntoCache() {
public ResponseEntity<String> reloadSchoolDetailsIntoCache() {
log.debug("reloadSchoolDetailsIntoCache : ");
try {
schoolService.initializeSchoolDetailCache(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.web.reactive.function.client.WebClientResponseException;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Slf4j
Expand Down Expand Up @@ -57,7 +58,7 @@ public List<District> getDistrictsFromInstituteApi() {
} catch (Exception e) {
log.error(String.format("Error while calling institute-api: %s", e.getMessage()));
}
return null;
return Collections.emptyList();
}

public District getDistrictByIdFromInstituteApi(String districtId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.web.servlet.MockMvc;

import java.util.ArrayList;
import java.util.List;

@ExtendWith(MockitoExtension.class)
public class CodeControllerTest {
class CodeControllerTest {

@Mock
private CodeService codeService;

@Mock
ResponseHelper response;

@InjectMocks
private CodeController codeController;

Expand All @@ -37,7 +35,7 @@ public class CodeControllerTest {
MessageHelper messagesHelper;

@Test
public void testGetAllCountryList() {
void testGetAllCountryList() {
List<GradCountry> gradCountryList = new ArrayList<>();
GradCountry obj = new GradCountry();
obj.setCountryCode("CA");
Expand All @@ -53,7 +51,7 @@ public void testGetAllCountryList() {
}

@Test
public void testGetSpecificCountryCode() {
void testGetSpecificCountryCode() {
String countryCode = "CA";
GradCountry obj = new GradCountry();
obj.setCountryCode("CA");
Expand All @@ -64,15 +62,15 @@ public void testGetSpecificCountryCode() {
}

@Test
public void testGetSpecificCountryCode_noContent() {
void testGetSpecificCountryCode_noContent() {
String countryCode = "AB";
Mockito.when(codeService.getSpecificCountryCode(countryCode)).thenReturn(null);
codeController.getSpecificCountryCode(countryCode);
Mockito.verify(codeService).getSpecificCountryCode(countryCode);
}

@Test
public void testGetAllProvinceList() {
void testGetAllProvinceList() {
List<GradProvince> gradProvinceList = new ArrayList<>();
GradProvince obj = new GradProvince();
obj.setProvCode("CA");
Expand All @@ -88,7 +86,7 @@ public void testGetAllProvinceList() {
}

@Test
public void testGetSpecificProvinceCode() {
void testGetSpecificProvinceCode() {
String countryCode = "CA";
GradProvince obj = new GradProvince();
obj.setProvCode("CA");
Expand All @@ -99,7 +97,7 @@ public void testGetSpecificProvinceCode() {
}

@Test
public void testGetSpecificProvinceCode_noContent() {
void testGetSpecificProvinceCode_noContent() {
String countryCode = "AB";
Mockito.when(codeService.getSpecificProvinceCode(countryCode)).thenReturn(null);
codeController.getSpecificProvinceCode(countryCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -26,7 +25,6 @@

import java.util.UUID;

import static org.mockito.Mockito.*;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,37 +340,6 @@ public void whenGetDistrictByIdFromRedisCache_ReturnDistrict() {

@Test
public void whenInitializeDistrictCache_WithReadyAndTrue_ThenForceLoad() {

District d = new District();
List<District> ds = new ArrayList<District>();
d.setDistrictId("123");
d.setDistrictNumber("456");
ds.add(d);
d = new District();
d.setDistrictId("789");
d.setDistrictNumber("012");
ds.add(d);

when(jedisClusterMock.get(CacheKey.DISTRICT_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
when(jedisClusterMock.set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.READY.name()))
.thenReturn("OK");
districtService.initializeDistrictCache(true);
verify(serviceHelper).initializeCache(true, CacheKey.DISTRICT_CACHE, districtService);
}

@Test
public void whenReloadDistrictsIntoCache_ThenForceLoad() {
District d = new District();
List<District> ds = new ArrayList<District>();
d.setDistrictId("123");
d.setDistrictNumber("456");
ds.add(d);
d = new District();
d.setDistrictId("789");
d.setDistrictNumber("012");
ds.add(d);

when(jedisClusterMock.get(CacheKey.DISTRICT_CACHE.name()))
.thenReturn(String.valueOf(CacheStatus.READY));
when(jedisClusterMock.set(CacheKey.DISTRICT_CACHE.name(), CacheStatus.READY.name()))
Expand Down

0 comments on commit 2aafe04

Please sign in to comment.