OozieSensitivityMetadataDAOImpl implements OozieSensitivityMetadataDAO { @Override public Map<String, Map<String, String>> getAllOozieSensitivityMap() { GenericEntityServiceResource resource = new GenericEntityServiceResource(); GenericServiceAPIResponseEntity ret = resource.search("OozieResourceSensitivityService[]{*}", 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, Map<String, String>> res = new HashMap<String, Map<String, String>>(); for (OozieResourceSensitivityAPIEntity entity : list) { String site = entity.getTags().get("site"); if (entity.getTags().containsKey("oozieResource")) { if (res.get(site) == null) { res.put(site, new HashMap<String, String>()); } Map<String, String> resSensitivityMap = res.get(site); resSensitivityMap.put(entity.getTags().get("oozieResource"), entity.getSensitivityType()); } else { if (LOG.isDebugEnabled()) { LOG.debug("An invalid sensitivity entity is detected" + entity); } } } return res; }  @Override Map<String, Map<String, String>> getAllOozieSensitivityMap(); @Override Map<String, String> getOozieSensitivityMap(String site);  }
@Test public void testGetAllOozieSensitivityMap() throws Exception { String[] sites = new String[]{"test", "test"}; mockGenericEntityServiceResourceSearchMethod("OozieResourceSensitivityService[]{*}",sites); OozieSensitivityMetadataDAO oozieSensitivityMetadataDAO = new OozieSensitivityMetadataDAOImpl(); Map<String, Map<String, String>> allOozieSensitivityMap = oozieSensitivityMetadataDAO.getAllOozieSensitivityMap(); Assert.assertEquals(1, allOozieSensitivityMap.size()); Assert.assertTrue(allOozieSensitivityMap.containsKey("test")); Assert.assertTrue(allOozieSensitivityMap.get("test").containsKey("0007197-160509174709457-oozie-oozi-C")); Assert.assertEquals("pms job", allOozieSensitivityMap.get("test").get("0007197-160509174709457-oozie-oozi-C")); Assert.assertTrue(allOozieSensitivityMap.get("test").containsKey("0007189-160509174709457-oozie-oozi-C")); Assert.assertEquals("tandem job", allOozieSensitivityMap.get("test").get("0007189-160509174709457-oozie-oozi-C")); }
@Test public void testGetAllOozieSensitivityMapWithDiffSite() throws Exception { String[] sites = new String[]{"test", "test1"}; mockGenericEntityServiceResourceSearchMethod("OozieResourceSensitivityService[]{*}",sites); OozieSensitivityMetadataDAO oozieSensitivityMetadataDAO = new OozieSensitivityMetadataDAOImpl(); Map<String, Map<String, String>> allOozieSensitivityMap = oozieSensitivityMetadataDAO.getAllOozieSensitivityMap(); Assert.assertEquals(2, allOozieSensitivityMap.size()); Assert.assertTrue(allOozieSensitivityMap.containsKey("test")); Assert.assertTrue(allOozieSensitivityMap.containsKey("test1")); Assert.assertTrue(allOozieSensitivityMap.get("test1").containsKey("0007197-160509174709457-oozie-oozi-C")); Assert.assertEquals("pms job", allOozieSensitivityMap.get("test1").get("0007197-160509174709457-oozie-oozi-C")); Assert.assertTrue(allOozieSensitivityMap.get("test").containsKey("0007189-160509174709457-oozie-oozi-C")); Assert.assertEquals("tandem job", allOozieSensitivityMap.get("test").get("0007189-160509174709457-oozie-oozi-C")); }