@Test public void getParametersIncludeTrackedEntities() { Mockito.when( metadataExportService.exp( Mockito.notNull() ) ).thenAnswer( (Answer<JsonNode>) invocation -> { final MetadataExportParams params = invocation.getArgument( 0 ); Assert.assertNotNull( params ); Assert.assertTrue( params.getTrackerProgramIds().isEmpty() ); Assert.assertTrue( params.getExcludedSystemUris().isEmpty() ); Assert.assertTrue( params.isIncludeTrackedEntities() ); Assert.assertTrue( params.isIncludeResourceMappings() ); return JsonNodeFactory.instance.textNode( "Test1" ); } ); final ResponseEntity<JsonNode> responseEntity = metadataRestController.exp( null, null, true, true, false ); Assert.assertEquals( HttpStatus.OK, responseEntity.getStatusCode() ); Assert.assertNull( responseEntity.getHeaders().getFirst( HttpHeaders.CONTENT_DISPOSITION ) ); Assert.assertEquals( JsonNodeFactory.instance.textNode( "Test1" ), responseEntity.getBody() ); Mockito.verify( metadataExportService ).exp( Mockito.notNull() ); }
@Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) public ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds, @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris, @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities, @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings, @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ) { final MetadataExportParams params = new MetadataExportParams(); params.setIncludeTrackedEntities( includeTrackedEntities ); params.setIncludeResourceMappings( includeResourceMappings ); if ( trackerProgramIds != null ) { params.getTrackerProgramIds().addAll( trackerProgramIds ); } if ( excludedSystemUris != null ) { params.getExcludedSystemUris().addAll( excludedSystemUris ); } final JsonNode node = metadataExportService.exp( params ); final HttpHeaders headers = new HttpHeaders(); if ( download ) { headers.set( HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"metadata.json\"" ); } return new ResponseEntity<>( node, headers, HttpStatus.OK ); }
MetadataRestController { @Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) public ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds, @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris, @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities, @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings, @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ) { final MetadataExportParams params = new MetadataExportParams(); params.setIncludeTrackedEntities( includeTrackedEntities ); params.setIncludeResourceMappings( includeResourceMappings ); if ( trackerProgramIds != null ) { params.getTrackerProgramIds().addAll( trackerProgramIds ); } if ( excludedSystemUris != null ) { params.getExcludedSystemUris().addAll( excludedSystemUris ); } final JsonNode node = metadataExportService.exp( params ); final HttpHeaders headers = new HttpHeaders(); if ( download ) { headers.set( HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"metadata.json\"" ); } return new ResponseEntity<>( node, headers, HttpStatus.OK ); } }
MetadataRestController { @Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) public ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds, @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris, @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities, @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings, @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ) { final MetadataExportParams params = new MetadataExportParams(); params.setIncludeTrackedEntities( includeTrackedEntities ); params.setIncludeResourceMappings( includeResourceMappings ); if ( trackerProgramIds != null ) { params.getTrackerProgramIds().addAll( trackerProgramIds ); } if ( excludedSystemUris != null ) { params.getExcludedSystemUris().addAll( excludedSystemUris ); } final JsonNode node = metadataExportService.exp( params ); final HttpHeaders headers = new HttpHeaders(); if ( download ) { headers.set( HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"metadata.json\"" ); } return new ResponseEntity<>( node, headers, HttpStatus.OK ); } MetadataRestController( @Nonnull MetadataExportService metadataExportService, @Nonnull MetadataImportService metadataImportService ); }
MetadataRestController { @Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) public ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds, @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris, @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities, @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings, @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ) { final MetadataExportParams params = new MetadataExportParams(); params.setIncludeTrackedEntities( includeTrackedEntities ); params.setIncludeResourceMappings( includeResourceMappings ); if ( trackerProgramIds != null ) { params.getTrackerProgramIds().addAll( trackerProgramIds ); } if ( excludedSystemUris != null ) { params.getExcludedSystemUris().addAll( excludedSystemUris ); } final JsonNode node = metadataExportService.exp( params ); final HttpHeaders headers = new HttpHeaders(); if ( download ) { headers.set( HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"metadata.json\"" ); } return new ResponseEntity<>( node, headers, HttpStatus.OK ); } MetadataRestController( @Nonnull MetadataExportService metadataExportService, @Nonnull MetadataImportService metadataImportService ); @Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds,
        @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris,
        @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities,
        @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings,
        @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ); @Nonnull @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) ResponseEntity<MetadataImportResult> imp( @RequestBody @Nonnull JsonNode jsonNode,
        @RequestParam( name = "updateResourceMappings", required = false, defaultValue = "false" ) boolean updateResourceMappings,
        @RequestParam( name = "updateCodes", required = false, defaultValue = "false" ) boolean updateCodes,
        @RequestParam( name = "updateScripts", required = false, defaultValue = "false" ) boolean updateScripts ); }
MetadataRestController { @Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) public ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds, @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris, @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities, @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings, @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ) { final MetadataExportParams params = new MetadataExportParams(); params.setIncludeTrackedEntities( includeTrackedEntities ); params.setIncludeResourceMappings( includeResourceMappings ); if ( trackerProgramIds != null ) { params.getTrackerProgramIds().addAll( trackerProgramIds ); } if ( excludedSystemUris != null ) { params.getExcludedSystemUris().addAll( excludedSystemUris ); } final JsonNode node = metadataExportService.exp( params ); final HttpHeaders headers = new HttpHeaders(); if ( download ) { headers.set( HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"metadata.json\"" ); } return new ResponseEntity<>( node, headers, HttpStatus.OK ); } MetadataRestController( @Nonnull MetadataExportService metadataExportService, @Nonnull MetadataImportService metadataImportService ); @Nonnull @RequestMapping( method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) ResponseEntity<JsonNode> exp( @RequestParam( name = "trackerProgramId", required = false ) List<UUID> trackerProgramIds,
        @RequestParam( name = "excludedSystemUri", required = false ) List<String> excludedSystemUris,
        @RequestParam( name = "includeTrackedEntities", required = false, defaultValue = "false" ) boolean includeTrackedEntities,
        @RequestParam( name = "includeResourceMappings", required = false, defaultValue = "false" ) boolean includeResourceMappings,
        @RequestParam( name = "download", required = false, defaultValue = "false" ) boolean download ); @Nonnull @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE ) @PreAuthorize( "hasRole('CODE_MAPPING') and hasRole('DATA_MAPPING')" ) ResponseEntity<MetadataImportResult> imp( @RequestBody @Nonnull JsonNode jsonNode,
        @RequestParam( name = "updateResourceMappings", required = false, defaultValue = "false" ) boolean updateResourceMappings,
        @RequestParam( name = "updateCodes", required = false, defaultValue = "false" ) boolean updateCodes,
        @RequestParam( name = "updateScripts", required = false, defaultValue = "false" ) boolean updateScripts );  }