Skip to content

Commit

Permalink
Add covid only flag for resend mutation (#7790)
Browse files Browse the repository at this point in the history
* Add covid only flag for resend mutation

* Update conditionals

* Make booleans conditional for resend mutation

* Update graphql codegen
  • Loading branch information
mpbrown authored Jun 11, 2024
1 parent 496bd29 commit 2e7e3b4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ public class TestResultMutationResolver {
@MutationMapping
@AuthorizationConfiguration.RequireGlobalAdminUser
public boolean resendToReportStream(
@Argument List<UUID> testEventIds, @Argument boolean fhirOnly) {
@Argument List<UUID> testEventIds, @Argument boolean fhirOnly, @Argument boolean covidOnly) {
testEventRepository
.findAllByInternalIdIn(testEventIds)
.forEach(
testEvent -> {
if (!fhirOnly) {
if (fhirOnly) {
fhirReportingService.report(testEvent);
} else if (covidOnly) {
testEventReportingService.report(testEvent);
} else {
testEventReportingService.report(testEvent);
fhirReportingService.report(testEvent);
}
fhirReportingService.report(testEvent);
});

return true;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/graphql/admin.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extend type Query {
getOrgAdminUserIds(orgId: ID!): [ID]
}
extend type Mutation {
resendToReportStream(testEventIds: [ID!]!, fhirOnly: Boolean!): Boolean
resendToReportStream(testEventIds: [ID!]!, fhirOnly: Boolean = false, covidOnly: Boolean = false): Boolean
createDeviceType(input: CreateDeviceType!): DeviceType
updateDeviceType(input: UpdateDeviceType!): DeviceType
createSpecimenType(input: CreateSpecimenType!): SpecimenType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void resendToReportStream_success() {

var actual =
testResultMutationResolver.resendToReportStream(
List.of(UUID.randomUUID(), UUID.randomUUID()), false);
List.of(UUID.randomUUID(), UUID.randomUUID()), false, false);

verify(mockCsvReporter, times(2)).report(any());
verify(mockFhirReporter, times(2)).report(any());
Expand All @@ -50,10 +50,30 @@ void resendToReportStream_fhirOnly_success() {

var actual =
testResultMutationResolver.resendToReportStream(
List.of(UUID.randomUUID(), UUID.randomUUID()), true);
List.of(UUID.randomUUID(), UUID.randomUUID()), true, false);

verify(mockCsvReporter, times(0)).report(any());
verify(mockFhirReporter, times(2)).report(any());
assertThat(actual).isTrue();
}

@Test
void resendToReportStream_covidOnly_success() {
var mockCsvReporter = mock(TestEventReportingService.class);
var mockFhirReporter = mock(TestEventReportingService.class);
var mockTestEventRepository = mock(TestEventRepository.class);

when(mockTestEventRepository.findAllByInternalIdIn(any()))
.thenReturn(List.of(createCovidTestEvent(), createMultiplexTestEvent()));
var testResultMutationResolver =
new TestResultMutationResolver(mockTestEventRepository, mockCsvReporter, mockFhirReporter);

var actual =
testResultMutationResolver.resendToReportStream(
List.of(UUID.randomUUID(), UUID.randomUUID()), false, true);

verify(mockCsvReporter, times(2)).report(any());
verify(mockFhirReporter, times(0)).report(any());
assertThat(actual).isTrue();
}
}
3 changes: 2 additions & 1 deletion frontend/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ export type MutationResendActivationEmailArgs = {
};

export type MutationResendToReportStreamArgs = {
fhirOnly: Scalars["Boolean"]["input"];
covidOnly?: InputMaybe<Scalars["Boolean"]["input"]>;
fhirOnly?: InputMaybe<Scalars["Boolean"]["input"]>;
testEventIds: Array<Scalars["ID"]["input"]>;
};

Expand Down

0 comments on commit 2e7e3b4

Please sign in to comment.