Skip to content

Commit

Permalink
Added CodeServicesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
agordon-vivid committed Dec 1, 2024
1 parent 268a7af commit 6646bd6
Show file tree
Hide file tree
Showing 3 changed files with 360 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,75 +25,81 @@
@Slf4j
@Component
public class CodesService implements CommonService {
private ForestAreaCodeRepository forestAreaCodeRepository;
private ForestAreaCodeResourceAssembler forestAreaCodeResourceAssembler;
private GeneralScopeCodeRepository generalScopeCodeRepository;
private GeneralScopeCodeResourceAssembler generalScopeCodeResourceAssembler;
private ProjectTypeCodeRepository projectTypeCodeRepository;
private ProjectTypeCodeResourceAssembler projectTypeCodeResourceAssembler;
private ForestAreaCodeRepository forestAreaCodeRepository;
private ForestAreaCodeResourceAssembler forestAreaCodeResourceAssembler;
private GeneralScopeCodeRepository generalScopeCodeRepository;
private GeneralScopeCodeResourceAssembler generalScopeCodeResourceAssembler;
private ProjectTypeCodeRepository projectTypeCodeRepository;
private ProjectTypeCodeResourceAssembler projectTypeCodeResourceAssembler;

public CodesService(ForestAreaCodeRepository forestAreaCodeRepository, ForestAreaCodeResourceAssembler forestAreaCodeResourceAssembler,
GeneralScopeCodeRepository generalScopeCodeRepository, GeneralScopeCodeResourceAssembler generalScopeCodeResourceAssembler,
ProjectTypeCodeRepository projectTypeCodeRepository, ProjectTypeCodeResourceAssembler projectTypeCodeResourceAssembler) {
this.forestAreaCodeRepository = forestAreaCodeRepository;
this.forestAreaCodeResourceAssembler = forestAreaCodeResourceAssembler;
this.generalScopeCodeRepository = generalScopeCodeRepository;
this.generalScopeCodeResourceAssembler = generalScopeCodeResourceAssembler;
this.projectTypeCodeRepository = projectTypeCodeRepository;
this.projectTypeCodeResourceAssembler = projectTypeCodeResourceAssembler;
}
public CodesService(ForestAreaCodeRepository forestAreaCodeRepository, ForestAreaCodeResourceAssembler forestAreaCodeResourceAssembler,
GeneralScopeCodeRepository generalScopeCodeRepository, GeneralScopeCodeResourceAssembler generalScopeCodeResourceAssembler,
ProjectTypeCodeRepository projectTypeCodeRepository, ProjectTypeCodeResourceAssembler projectTypeCodeResourceAssembler) {
this.forestAreaCodeRepository = forestAreaCodeRepository;
this.forestAreaCodeResourceAssembler = forestAreaCodeResourceAssembler;
this.generalScopeCodeRepository = generalScopeCodeRepository;
this.generalScopeCodeResourceAssembler = generalScopeCodeResourceAssembler;
this.projectTypeCodeRepository = projectTypeCodeRepository;
this.projectTypeCodeResourceAssembler = projectTypeCodeResourceAssembler;
}

/** FOREST AREA CODES **/
public CollectionModel<ForestAreaCodeModel> getAllForestAreaCodes() throws ServiceException {
try {
List<ForestAreaCodeEntity> entities = new ArrayList<>();
return forestAreaCodeResourceAssembler.toCollectionModel(entities);
} catch(Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
/**
* FOREST AREA CODES
**/
public CollectionModel<ForestAreaCodeModel> getAllForestAreaCodes() throws ServiceException {
try {
List<ForestAreaCodeEntity> entities = forestAreaCodeRepository.findAll();
return forestAreaCodeResourceAssembler.toCollectionModel(entities);
} catch (Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

public ForestAreaCodeModel getForestAreaCodeById(String id) throws ServiceException {
try {
return forestAreaCodeRepository.findById(id).map(forestAreaCodeResourceAssembler::toModel).orElse(null);
} catch(Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);

public ForestAreaCodeModel getForestAreaCodeById(String id) throws ServiceException {
try {
return forestAreaCodeRepository.findById(id).map(forestAreaCodeResourceAssembler::toModel).orElse(null);
} catch (Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

/** GENERAL SCOPE CODES **/
public CollectionModel<GeneralScopeCodeModel> getAllGeneralScopeCodes() throws ServiceException {
try {
List<GeneralScopeCodeEntity> entities = new ArrayList<>();
return generalScopeCodeResourceAssembler.toCollectionModel(entities);
} catch(Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
/**
* GENERAL SCOPE CODES
**/
public CollectionModel<GeneralScopeCodeModel> getAllGeneralScopeCodes() throws ServiceException {
try {
List<GeneralScopeCodeEntity> entities = generalScopeCodeRepository.findAll();
return generalScopeCodeResourceAssembler.toCollectionModel(entities);
} catch (Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

public GeneralScopeCodeModel getGeneralScopeCodeById(String id) throws ServiceException {
try {
return generalScopeCodeRepository.findById(id).map(generalScopeCodeResourceAssembler::toModel).orElse(null);
} catch(Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);

public GeneralScopeCodeModel getGeneralScopeCodeById(String id) throws ServiceException {
try {
return generalScopeCodeRepository.findById(id).map(generalScopeCodeResourceAssembler::toModel).orElse(null);
} catch (Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

/** PROJECT TYPE CODES **/
public CollectionModel<ProjectTypeCodeModel> getAllProjectTypeCodes() throws ServiceException {
try {
List<ProjectTypeCodeEntity> entities = new ArrayList<>();
return projectTypeCodeResourceAssembler.toCollectionModel(entities);
} catch(Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
/**
* PROJECT TYPE CODES
**/
public CollectionModel<ProjectTypeCodeModel> getAllProjectTypeCodes() throws ServiceException {
try {
List<ProjectTypeCodeEntity> entities = projectTypeCodeRepository.findAll();
return projectTypeCodeResourceAssembler.toCollectionModel(entities);
} catch (Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

public ProjectTypeCodeModel getProjectTypeCodeById(String id) throws ServiceException {
try {
return projectTypeCodeRepository.findById(id).map(projectTypeCodeResourceAssembler::toModel).orElse(null);
} catch(Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);

public ProjectTypeCodeModel getProjectTypeCodeById(String id) throws ServiceException {
try {
return projectTypeCodeRepository.findById(id).map(projectTypeCodeResourceAssembler::toModel).orElse(null);
} catch (Exception e) {
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}
}
Loading

0 comments on commit 6646bd6

Please sign in to comment.