EmrClusterDefinitionDaoHelper { public List<EmrClusterDefinitionKey> getEmrClusterDefinitionKeys(String namespace) { NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(namespace); if (namespaceEntity != null) { return emrClusterDefinitionDao.getEmrClusterDefinitionKeysByNamespace(namespaceEntity); } else { return Lists.newArrayList(); } }  EmrClusterDefinitionEntity getEmrClusterDefinitionEntity(EmrClusterDefinitionKey emrClusterDefinitionKey); List<EmrClusterDefinitionKey> getEmrClusterDefinitionKeys(String namespace);  }
@Test public void testGetEmrClusterDefinitionKeys() { NamespaceEntity namespaceEntity = new NamespaceEntity(); List<EmrClusterDefinitionKey> emrClusterDefinitionKeys = Lists.newArrayList(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME)); when(namespaceDao.getNamespaceByCd(NAMESPACE)).thenReturn(namespaceEntity); when(emrClusterDefinitionDao.getEmrClusterDefinitionKeysByNamespace(namespaceEntity)).thenReturn(emrClusterDefinitionKeys); List<EmrClusterDefinitionKey> result = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionKeys(NAMESPACE); verify(namespaceDao).getNamespaceByCd(NAMESPACE); verify(emrClusterDefinitionDao).getEmrClusterDefinitionKeysByNamespace(namespaceEntity); verifyNoMoreInteractionsHelper(); assertEquals(emrClusterDefinitionKeys, result); }
@Test public void testGetEmrClusterDefinitionKeysNamespaceNoExists() { when(namespaceDao.getNamespaceByCd(NAMESPACE)).thenReturn(null); List<EmrClusterDefinitionKey> result = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionKeys(NAMESPACE); verify(namespaceDao).getNamespaceByCd(NAMESPACE); verifyNoMoreInteractionsHelper(); assertNotNull(result); assertEquals(0, result.size()); }