ProductMetadata { public Map<String, Object> getContextMap() { Map<String, Object> contextMap = new HashMap<>(); contextMap.put("jobFinishTime", jobFinishTime); contextMap.put("productOutputDir", productOutputDir); contextMap.put("productionName", productionName); contextMap.put("processName", processName); contextMap.put("processorId", processorId); contextMap.put("inputDatasetName", inputDatasetName); contextMap.put("regionWkt", regionWkt); contextMap.put("regionBox", regionBox); contextMap.put("startDate", startDate); contextMap.put("stopDate", stopDate); contextMap.put("collectionUrl", collectionUrl); contextMap.put("processorVersion", processorVersion); contextMap.put("productionType", productionType); contextMap.put("outputFormat", outputFormat); contextMap.put("productList", productList); contextMap.put("quickLookProductUrlList", quickLookProductUrlList); return contextMap; } ProductMetadata(ProductMetadataBuilder builder); Map<String, Object> getContextMap();  }
@Test public void canCreateProductMetadata() throws Exception { configureMockProduction("TEP Subset test"); List<File> mockProductionFileList = new ArrayList<>(); File mockFile1 = getMockFile("result1.nc", 1000000000L); mockProductionFileList.add(mockFile1); File mockFile2 = getMockFile("result.zip", 1000000L); mockProductionFileList.add(mockFile2); File mockFile3 = getMockFile("result-metadata", 5000L); mockProductionFileList.add(mockFile3); File mockFile4 = getMockFile("result.xml", 1000L); mockProductionFileList.add(mockFile4); File mockFile5 = getMockFile("quicklook.png", 2000L); mockProductionFileList.add(mockFile5); ProductMetadata productMetadata = ProductMetadataBuilder.create() .withProduction(mockProduction) .withProductionResults(mockProductionFileList) .withServerContext(mockServerContext) .build(); Map<String, Object> contextMap = productMetadata.getContextMap(); assertThat(contextMap.get("jobFinishTime"), equalTo("2016-01-01T01:00:00.000+01:00")); assertThat(contextMap.get("productOutputDir"), equalTo("user/20160317_10000000")); assertThat(contextMap.get("productionName"), equalTo("TEP_Subset_test")); assertThat(contextMap.get("processName"), equalTo("Subset")); assertThat(contextMap.get("inputDatasetName"), equalTo("Urban Footprint Global (Urban TEP)")); assertThat(contextMap.get("regionWkt"), equalTo("-10 100 0 100 0 110 -10 110 -10 100")); assertThat(contextMap.get("startDate"), equalTo("2000-01-01T01:00:00.000+01:00")); assertThat(contextMap.get("stopDate"), equalTo("2020-01-01T01:00:00.000+01:00")); assertThat(contextMap.get("collectionUrl"), equalTo("http: assertThat(contextMap.get("processorVersion"), equalTo("1.0")); assertThat(contextMap.get("productionType"), equalTo("2")); assertThat(contextMap.get("outputFormat"), equalTo("NetCDF4")); List productionList = (List) contextMap.get("productList"); assertThat(productionList.size(), equalTo(3)); Map product1 = (Map) productionList.get(0); assertThat(product1.get("productFileName"), equalTo("result1.nc")); assertThat(product1.get("productFileFormat"), equalTo("NetCDF4")); assertThat(product1.get("productFileSize"), equalTo("1000000000")); assertThat(product1.get("productUrl"), equalTo("http: Map product2 = (Map) productionList.get(1); assertThat(product2.get("productFileName"), equalTo("result-metadata")); assertThat(product2.get("productFileFormat"), equalTo("metadata")); assertThat(product2.get("productFileSize"), equalTo("5000")); assertThat(product2.get("productUrl"), equalTo("http: Map product3 = (Map) productionList.get(2); assertThat(product3.get("productFileName"), equalTo("result.xml")); assertThat(product3.get("productFileFormat"), equalTo("XML")); assertThat(product3.get("productFileSize"), equalTo("1000")); assertThat(product3.get("productUrl"), equalTo("http: List quickLookUrlList = (List) contextMap.get("quickLookProductUrlList"); assertThat(quickLookUrlList.size(), equalTo(1)); assertThat(quickLookUrlList.get(0), equalTo("http: }
@Test public void canEncodeProductionNameWithSpecialChars() throws Exception { configureMockProduction("http: List<File> mockProductionFileList = new ArrayList<>(); ProductMetadata productMetadata = ProductMetadataBuilder.create() .withProduction(mockProduction) .withProductionResults(mockProductionFileList) .withServerContext(mockServerContext) .build(); Map<String, Object> contextMap = productMetadata.getContextMap(); assertThat(contextMap.get("jobFinishTime"), equalTo("2016-01-01T01:00:00.000+01:00")); assertThat(contextMap.get("productOutputDir"), equalTo("user/20160317_10000000")); assertThat(contextMap.get("productionName"), equalTo("http%3A%2F%2Fcatalog.terradue.com%2Furban-bc%2Fsearch%3Fformat%3Djson%26uid%3Dtep_inverted_timescan_Dakar%2Ftep_user%2F20170427185240_L3_130ec6a9dc24be")); assertThat(contextMap.get("processName"), equalTo("Subset")); assertThat(contextMap.get("inputDatasetName"), equalTo("Urban Footprint Global (Urban TEP)")); assertThat(contextMap.get("regionWkt"), equalTo("-10 100 0 100 0 110 -10 110 -10 100")); assertThat(contextMap.get("startDate"), equalTo("2000-01-01T01:00:00.000+01:00")); assertThat(contextMap.get("stopDate"), equalTo("2020-01-01T01:00:00.000+01:00")); assertThat(contextMap.get("collectionUrl"), equalTo("http: assertThat(contextMap.get("processorVersion"), equalTo("1.0")); assertThat(contextMap.get("productionType"), equalTo("2")); assertThat(contextMap.get("outputFormat"), equalTo("NetCDF4")); List productionList = (List) contextMap.get("productList"); assertThat(productionList.size(), equalTo(0)); }