OozieSensitivityMetadataDAOImpl implements OozieSensitivityMetadataDAO { @Override public Map<String, String> getOozieSensitivityMap(String site) { GenericEntityServiceResource resource = new GenericEntityServiceResource(); String queryFormat = "OozieResourceSensitivityService[@site=\"%s\"]{*}"; GenericServiceAPIResponseEntity ret = resource.search(String.format(queryFormat, site), null, null, Integer.MAX_VALUE, null, false, false, 0L, 0, false, 0, null, false); List<OozieResourceSensitivityAPIEntity> list = (List<OozieResourceSensitivityAPIEntity>) ret.getObj(); if (list == null) { return Collections.emptyMap(); } Map<String, String> resSensitivityMap = new HashMap<String, String>(); for (OozieResourceSensitivityAPIEntity entity : list) { if (entity.getTags().containsKey("oozieResource")) { resSensitivityMap.put(entity.getTags().get("oozieResource"), entity.getSensitivityType()); } } return resSensitivityMap; }  @Override Map<String, Map<String, String>> getAllOozieSensitivityMap(); @Override Map<String, String> getOozieSensitivityMap(String site);  }
@Test public void testGetOozieSensitivityMap() throws Exception { String[] sites = new String[]{"test", "test"}; mockGenericEntityServiceResourceSearchMethod("OozieResourceSensitivityService[@site=\"test\"]{*}",sites); OozieSensitivityMetadataDAO oozieSensitivityMetadataDAO = new OozieSensitivityMetadataDAOImpl(); Map<String, String> oozieSensitivityMap = oozieSensitivityMetadataDAO.getOozieSensitivityMap("test"); Assert.assertEquals(2, oozieSensitivityMap.size()); Assert.assertTrue(oozieSensitivityMap.containsKey("0007197-160509174709457-oozie-oozi-C")); Assert.assertTrue(oozieSensitivityMap.containsKey("0007189-160509174709457-oozie-oozi-C")); Assert.assertEquals("pms job", oozieSensitivityMap.get("0007197-160509174709457-oozie-oozi-C")); Assert.assertEquals("tandem job", oozieSensitivityMap.get("0007189-160509174709457-oozie-oozi-C")); }