Skip to content

Commit

Permalink
Updates zip code query to big int and the County zip_code to long
Browse files Browse the repository at this point in the history
  • Loading branch information
analoo committed Feb 10, 2025
1 parent 772a4f6 commit 58823d3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/ilgcc/app/data/County.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class County implements Serializable {

@Id
@Column(name = "zip_code")
private String zipCode;
private Long zipCode;

@Column(name = "city")
private String city;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/ilgcc/app/data/CountyRepository.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.ilgcc.app.data;

import java.math.BigInteger;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface CountyRepository extends JpaRepository<County, String> {

Optional<County> findByZipCode(String truncatedZip);
Optional<County> findByZipCode(BigInteger truncatedZip);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public CCMSDataServiceImpl(ProviderRepository providerRepository, CountyReposito
@Override
public Optional<County> getCountyByZipCode(String zipCode) {
final String truncatedZip = zipCode.substring(0, 5);
return countyRepository.findByZipCode(truncatedZip);
final BigInteger zipCodeInt = new BigInteger(truncatedZip);
return countyRepository.findByZipCode(zipCodeInt);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void setUp() {
action.applicationRouterService = applicationRouterService;
action.submissionRepositoryService = submissionRepositoryService;
action.ccmsDataServiceImpl=ccmsDataServiceImpl;
County cookCounty = new County("60304", "city" , "Cook", 123, 123, "AA" );
County cookCounty = new County(Long.parseLong("60304"), "city" , "Cook", 123, 123, "AA" );
when(ccmsDataServiceImpl.getCountyByZipCode("60304")).thenReturn(Optional.of(cookCounty));
}

Expand All @@ -65,7 +65,7 @@ public void setsOrganizationIdFromParentHomeAddressIfNotValidated() {
.with("applicationCounty", CountyOption.LEE.getValue())
.build();

County jasperCounty = new County("62479", "city" , "Jasper", 123, 123, "AA" );
County jasperCounty = new County(Long.parseLong("62479"), "city" , "Jasper", 123, 123, "AA" );
when(ccmsDataServiceImpl.getCountyByZipCode("62479")).thenReturn(Optional.of(jasperCounty));

action.run(submission);
Expand Down

0 comments on commit 58823d3

Please sign in to comment.