Skip to content

Commit

Permalink
Merge pull request #17 from usd-cs/chore/validation
Browse files Browse the repository at this point in the history
Fixed unexpeced protobuf formatting issues
  • Loading branch information
natjungquist authored Dec 13, 2024
2 parents 5a9493b + b7f17f3 commit 804576b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_GOOGLE_JAVA_FORMAT: true
VALIDATE_JAVASCRIPT_STANDARD: true
VALIDATE_PROTOBUF: true
VALIDATE_PROTOBUF: true
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void validateRequest(FetcherRequest request) {
String.format("Expected fetcher_type 'direct_fetcher', but got '%s'",
request.getFetcherTypeCase().toString().toLowerCase()));
}
if (request.getDirectFetcher().getDirectType() != DirectType.DEPARTMENTS) {
if (request.getDirectFetcher().getDirectType() != DirectType.DIRECT_TYPE_DEPARTMENTS) {
throw new IllegalArgumentException(String.format(
"Expected DirectType 'DEPARTMENTS', but got '%s'. This fetcher only supports DEPARTMENTS type",
request.getDirectFetcher().getDirectType()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void validateConfig(ModuleConfig moduleConfig) {
}

private FetcherResponse handleDirectFetcher(FetcherRequest request) {
if (request.getDirectFetcher().getDirectType() == DirectType.DEPARTMENTS) {
if (request.getDirectFetcher().getDirectType() == DirectType.DIRECT_TYPE_DEPARTMENTS) {
return departmentFetcher.fetch(request);
}
// Add more cases as we add more direct types.
Expand All @@ -64,7 +64,7 @@ private FetcherResponse handleDirectFetcher(FetcherRequest request) {

private FetcherResponse handleFilteredFetcher(FetcherRequest request) {
if (request.getFilteredFetcher()
.getFilteredType() == FilteredType.PROJECTS) {
.getFilteredType() == FilteredType.FILTERED_TYPE_PROJECTS) {
return projectFetcher.fetch(request);
}
// Add more cases as we add more filtered types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ResponseEntity<List<DepartmentDTO>> getProjects() {
ModuleConfig moduleConfig = ModuleConfig.newBuilder()
.setFetcherRequest(
FetcherRequest.newBuilder().setFilteredFetcher(FilteredFetcher
.newBuilder().setFilteredType(FilteredType.PROJECTS)))
.newBuilder().setFilteredType(FilteredType.FILTERED_TYPE_PROJECTS)))
.build();
ModuleResponse moduleResponse = moduleInvoker.processConfig(moduleConfig);
return ResponseEntity.ok(moduleResponse.getFetcherResponse()
Expand Down
7 changes: 4 additions & 3 deletions backend/src/main/proto/fetcher/fetcher_module.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ message FetcherRequest {
oneof fetcher_type {
DirectFetcher direct_fetcher = 1;
FilteredFetcher filtered_fetcher = 2;
// We will need a filtered fetcher type in the future.
}
}

Expand All @@ -25,7 +24,8 @@ message DirectFetcher {
}

enum DirectType {
DEPARTMENTS = 0;
DIRECT_TYPE_UNSPECIFIED = 0;
DIRECT_TYPE_DEPARTMENTS = 1;
// Add more if needed, e.g. Majors, Umbrella topics, etc.
}

Expand All @@ -34,6 +34,7 @@ message FilteredFetcher {
}

enum FilteredType {
PROJECTS = 0;
FILTERED_TYPE_UNSPECIFIED = 0;
FILTERED_TYPE_PROJECTS = 1;
// Add more if needed, e.g. Students.
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testFetch_validRequest_returnsExpectedResponse() {

FetcherRequest request = FetcherRequest.newBuilder()
.setDirectFetcher(
DirectFetcher.newBuilder().setDirectType(DirectType.DEPARTMENTS))
DirectFetcher.newBuilder().setDirectType(DirectType.DIRECT_TYPE_DEPARTMENTS))
.build();
FetcherResponse response = departmentFetcher.fetch(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void setUp() {
public void testProcessConfig_validRequest_directType_returnsExpectedResponse() {
FetcherRequest mockRequest = FetcherRequest.newBuilder()
.setDirectFetcher(
DirectFetcher.newBuilder().setDirectType(DirectType.DEPARTMENTS))
DirectFetcher.newBuilder().setDirectType(DirectType.DIRECT_TYPE_DEPARTMENTS))
.build();

FetcherResponse mockResponse = FetcherResponse.newBuilder()
Expand All @@ -64,7 +64,7 @@ public void testProcessConfig_validRequest_directType_returnsExpectedResponse()
public void testProcessConfig_validRequest_filteredType_returnsExpectedResponse() {
FetcherRequest mockRequest = FetcherRequest.newBuilder()
.setFilteredFetcher(
FilteredFetcher.newBuilder().setFilteredType(FilteredType.PROJECTS))
FilteredFetcher.newBuilder().setFilteredType(FilteredType.FILTERED_TYPE_PROJECTS))
.build();

MajorWithProjects majorWithProjects =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testFetch_validRequest_returnsExpectedResponse() {

FetcherRequest request = FetcherRequest.newBuilder()
.setFilteredFetcher(
FilteredFetcher.newBuilder().setFilteredType(FilteredType.PROJECTS))
FilteredFetcher.newBuilder().setFilteredType(FilteredType.FILTERED_TYPE_PROJECTS))
.build();
FetcherResponse response = projectFetcher.fetch(request);

Expand Down Expand Up @@ -141,7 +141,7 @@ public void testFetch_projectWithMultipleMajors_returnsCorrectHierarchy() {
// Execute test
FetcherRequest request = FetcherRequest.newBuilder()
.setFilteredFetcher(
FilteredFetcher.newBuilder().setFilteredType(FilteredType.PROJECTS))
FilteredFetcher.newBuilder().setFilteredType(FilteredType.FILTERED_TYPE_PROJECTS))
.build();
FetcherResponse response = projectFetcher.fetch(request);

Expand Down Expand Up @@ -237,7 +237,7 @@ public void testFetch_projectInMultipleDepartments_returnsCorrectHierarchy() {
// Execute test
FetcherRequest request = FetcherRequest.newBuilder()
.setFilteredFetcher(
FilteredFetcher.newBuilder().setFilteredType(FilteredType.PROJECTS))
FilteredFetcher.newBuilder().setFilteredType(FilteredType.FILTERED_TYPE_PROJECTS))
.build();
FetcherResponse response = projectFetcher.fetch(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void setUp() {
public void testProcessConfig_validFetcherRequest_returnsExpectedResponse() {
FetcherRequest mockRequest = FetcherRequest.newBuilder()
.setDirectFetcher(
DirectFetcher.newBuilder().setDirectType(DirectType.DEPARTMENTS))
DirectFetcher.newBuilder().setDirectType(DirectType.DIRECT_TYPE_DEPARTMENTS))
.build();
FetcherResponse mockResponse = FetcherResponse.newBuilder()
.setDepartmentCollection(
Expand Down

0 comments on commit 804576b

Please sign in to comment.