@Test public void testCheckAndConvertToMediaType() throws FHIROperationException { Map<String, List<String>> _mvm = new HashMap<String, List<String>>(); _mvm.put("_outputFormat", Arrays.asList("application/fhir+ndjson")); MediaType type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+ndjson"); _mvm.clear(); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+ndjson"); _mvm.clear(); _mvm.put("_outputFormat", Collections.emptyList()); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+ndjson"); _mvm.clear(); _mvm.put("_outputFormat", Arrays.asList("application/fhir+parquet", "ndjson")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+parquet"); _mvm.clear(); _mvm.put("_outputFormat", Arrays.asList("application/fhir+parquet")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+parquet"); try { _mvm.clear(); _mvm.put("_outputFormat", Arrays.asList("application/json")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); fail(); } catch (FHIROperationException e) { assertNotNull(e); } try { _mvm.clear(); _mvm.put("_outputFormat", Arrays.asList("application/nd fred")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); fail(); } catch (FHIROperationException e) { assertNotNull(e); } _mvm.clear(); _mvm.put("_outputFormat", Arrays.asList("application/fhir ndjson")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+ndjson"); _mvm.put("_outputFormat", Arrays.asList("application/ndjson")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+ndjson"); _mvm.put("_outputFormat", Arrays.asList("ndjson")); type = BulkDataExportUtil.checkAndConvertToMediaType(generateParametersFromMap(_mvm)); assertNotNull(type); assertEquals(type.getType(), "application"); assertEquals(type.getSubtype(), "fhir+ndjson"); }
public static MediaType checkAndConvertToMediaType(Parameters parameters) throws FHIROperationException { Optional<Parameter> parameter = parameters.getParameter().stream() .filter(p -> BulkDataConstants.PARAM_OUTPUT_FORMAT.equals(p.getName().getValue())) .findFirst(); String mediaType = FHIRMediaType.APPLICATION_NDJSON; if (parameter.isPresent() && parameter.get().getValue().is(com.ibm.fhir.model.type.String.class)) { mediaType = retrieveOutputFormat(parameter.get().getValue().as(com.ibm.fhir.model.type.String.class).getValue()); } return MediaType.valueOf(mediaType); }
BulkDataExportUtil { public static MediaType checkAndConvertToMediaType(Parameters parameters) throws FHIROperationException { Optional<Parameter> parameter = parameters.getParameter().stream() .filter(p -> BulkDataConstants.PARAM_OUTPUT_FORMAT.equals(p.getName().getValue())) .findFirst(); String mediaType = FHIRMediaType.APPLICATION_NDJSON; if (parameter.isPresent() && parameter.get().getValue().is(com.ibm.fhir.model.type.String.class)) { mediaType = retrieveOutputFormat(parameter.get().getValue().as(com.ibm.fhir.model.type.String.class).getValue()); } return MediaType.valueOf(mediaType); } }
BulkDataExportUtil { public static MediaType checkAndConvertToMediaType(Parameters parameters) throws FHIROperationException { Optional<Parameter> parameter = parameters.getParameter().stream() .filter(p -> BulkDataConstants.PARAM_OUTPUT_FORMAT.equals(p.getName().getValue())) .findFirst(); String mediaType = FHIRMediaType.APPLICATION_NDJSON; if (parameter.isPresent() && parameter.get().getValue().is(com.ibm.fhir.model.type.String.class)) { mediaType = retrieveOutputFormat(parameter.get().getValue().as(com.ibm.fhir.model.type.String.class).getValue()); } return MediaType.valueOf(mediaType); } private  BulkDataExportUtil(); }
BulkDataExportUtil { public static MediaType checkAndConvertToMediaType(Parameters parameters) throws FHIROperationException { Optional<Parameter> parameter = parameters.getParameter().stream() .filter(p -> BulkDataConstants.PARAM_OUTPUT_FORMAT.equals(p.getName().getValue())) .findFirst(); String mediaType = FHIRMediaType.APPLICATION_NDJSON; if (parameter.isPresent() && parameter.get().getValue().is(com.ibm.fhir.model.type.String.class)) { mediaType = retrieveOutputFormat(parameter.get().getValue().as(com.ibm.fhir.model.type.String.class).getValue()); } return MediaType.valueOf(mediaType); } private  BulkDataExportUtil(); static BulkDataConstants.ExportType checkExportType(FHIROperationContext.Type type,
            Class<? extends Resource> resourceType); static MediaType checkAndConvertToMediaType(Parameters parameters); static FHIROperationException buildOperationException(String errMsg, IssueType issueType); static Instant checkAndExtractSince(Parameters parameters); static List<String> checkAndValidateTypes(Parameters parameters); static List<String> checkAndValidateTypeFilters(Parameters parameters); static Parameters getOutputParametersWithJson(PollingLocationResponse resource); static String checkAndValidateJob(Parameters parameters); static String encryptBatchJobId(String strToEncrypt, SecretKeySpec key); static String decryptBatchJobId(String strToDecrypt, SecretKeySpec key); }
BulkDataExportUtil { public static MediaType checkAndConvertToMediaType(Parameters parameters) throws FHIROperationException { Optional<Parameter> parameter = parameters.getParameter().stream() .filter(p -> BulkDataConstants.PARAM_OUTPUT_FORMAT.equals(p.getName().getValue())) .findFirst(); String mediaType = FHIRMediaType.APPLICATION_NDJSON; if (parameter.isPresent() && parameter.get().getValue().is(com.ibm.fhir.model.type.String.class)) { mediaType = retrieveOutputFormat(parameter.get().getValue().as(com.ibm.fhir.model.type.String.class).getValue()); } return MediaType.valueOf(mediaType); } private  BulkDataExportUtil(); static BulkDataConstants.ExportType checkExportType(FHIROperationContext.Type type,
            Class<? extends Resource> resourceType); static MediaType checkAndConvertToMediaType(Parameters parameters); static FHIROperationException buildOperationException(String errMsg, IssueType issueType); static Instant checkAndExtractSince(Parameters parameters); static List<String> checkAndValidateTypes(Parameters parameters); static List<String> checkAndValidateTypeFilters(Parameters parameters); static Parameters getOutputParametersWithJson(PollingLocationResponse resource); static String checkAndValidateJob(Parameters parameters); static String encryptBatchJobId(String strToEncrypt, SecretKeySpec key); static String decryptBatchJobId(String strToDecrypt, SecretKeySpec key);  }