@Test public void dateRangeIsRequired() { assertThatThrownBy(() -> resource.getMachineTranslationUsage(null)) .isInstanceOf(InvalidDateParamException.class); }
@Override public Response getMachineTranslationUsage(DateRange dateRange) { if (dateRange == null) { throw new InvalidDateParamException("dateRange is required"); } Optional<Account> account = this.authenticatedAccount.getAuthenticatedAccount(); if (!account.isPresent()) { return Response.status(Response.Status.UNAUTHORIZED).build(); } List<MTRequestStatistics> stats = reportingService .getMTRequestStats(account.get(), dateRange); GenericEntity<List<MTRequestStatistics>> entity = new GenericEntity<List<MTRequestStatistics>>(stats) { }; return Response.ok(entity).build(); }
ReportingResourceImpl implements ReportingResource { @Override public Response getMachineTranslationUsage(DateRange dateRange) { if (dateRange == null) { throw new InvalidDateParamException("dateRange is required"); } Optional<Account> account = this.authenticatedAccount.getAuthenticatedAccount(); if (!account.isPresent()) { return Response.status(Response.Status.UNAUTHORIZED).build(); } List<MTRequestStatistics> stats = reportingService .getMTRequestStats(account.get(), dateRange); GenericEntity<List<MTRequestStatistics>> entity = new GenericEntity<List<MTRequestStatistics>>(stats) { }; return Response.ok(entity).build(); } }
ReportingResourceImpl implements ReportingResource { @Override public Response getMachineTranslationUsage(DateRange dateRange) { if (dateRange == null) { throw new InvalidDateParamException("dateRange is required"); } Optional<Account> account = this.authenticatedAccount.getAuthenticatedAccount(); if (!account.isPresent()) { return Response.status(Response.Status.UNAUTHORIZED).build(); } List<MTRequestStatistics> stats = reportingService .getMTRequestStats(account.get(), dateRange); GenericEntity<List<MTRequestStatistics>> entity = new GenericEntity<List<MTRequestStatistics>>(stats) { }; return Response.ok(entity).build(); } ReportingResourceImpl(); @Inject  ReportingResourceImpl(
            ReportingService reportingService,
            AuthenticatedAccount authenticatedAccount); }
ReportingResourceImpl implements ReportingResource { @Override public Response getMachineTranslationUsage(DateRange dateRange) { if (dateRange == null) { throw new InvalidDateParamException("dateRange is required"); } Optional<Account> account = this.authenticatedAccount.getAuthenticatedAccount(); if (!account.isPresent()) { return Response.status(Response.Status.UNAUTHORIZED).build(); } List<MTRequestStatistics> stats = reportingService .getMTRequestStats(account.get(), dateRange); GenericEntity<List<MTRequestStatistics>> entity = new GenericEntity<List<MTRequestStatistics>>(stats) { }; return Response.ok(entity).build(); } ReportingResourceImpl(); @Inject  ReportingResourceImpl(
            ReportingService reportingService,
            AuthenticatedAccount authenticatedAccount); @Override Response getMachineTranslationUsage(DateRange dateRange); }
ReportingResourceImpl implements ReportingResource { @Override public Response getMachineTranslationUsage(DateRange dateRange) { if (dateRange == null) { throw new InvalidDateParamException("dateRange is required"); } Optional<Account> account = this.authenticatedAccount.getAuthenticatedAccount(); if (!account.isPresent()) { return Response.status(Response.Status.UNAUTHORIZED).build(); } List<MTRequestStatistics> stats = reportingService .getMTRequestStats(account.get(), dateRange); GenericEntity<List<MTRequestStatistics>> entity = new GenericEntity<List<MTRequestStatistics>>(stats) { }; return Response.ok(entity).build(); } ReportingResourceImpl(); @Inject  ReportingResourceImpl(
            ReportingService reportingService,
            AuthenticatedAccount authenticatedAccount); @Override Response getMachineTranslationUsage(DateRange dateRange);  }