use of org.finra.herd.dao.EmrDao in project herd by FINRAOS.
the class EmrHelperTest method testGetActiveEmrClusterIdAssertErrorWhenBothIdAndNameNotSpecified.
@Test
public void testGetActiveEmrClusterIdAssertErrorWhenBothIdAndNameNotSpecified() {
EmrDao originalEmrDao = emrHelper.getEmrDao();
EmrDao mockEmrDao = mock(EmrDao.class);
emrHelper.setEmrDao(mockEmrDao);
try {
String emrClusterId = null;
String emrClusterName = null;
try {
emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null);
fail();
} catch (IllegalArgumentException e) {
assertEquals("One of EMR cluster ID or EMR cluster name must be specified.", e.getMessage());
}
verifyNoMoreInteractions(mockEmrDao);
} finally {
emrHelper.setEmrDao(originalEmrDao);
}
}
use of org.finra.herd.dao.EmrDao in project herd by FINRAOS.
the class EmrHelperTest method testGetActiveEmrClusterIdAssertErrorWhenClusterIdSpecifiedAndClusterDoesNotExist.
@Test
public void testGetActiveEmrClusterIdAssertErrorWhenClusterIdSpecifiedAndClusterDoesNotExist() {
EmrDao originalEmrDao = emrHelper.getEmrDao();
EmrDao mockEmrDao = mock(EmrDao.class);
emrHelper.setEmrDao(mockEmrDao);
try {
String emrClusterId = "emrClusterId";
String emrClusterName = "emrClusterName";
when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(null);
try {
emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("The cluster with ID \"%s\" does not exist.", emrClusterId), e.getMessage());
}
verify(mockEmrDao).getEmrClusterById(eq(emrClusterId), any());
verifyNoMoreInteractions(mockEmrDao);
} finally {
emrHelper.setEmrDao(originalEmrDao);
}
}
use of org.finra.herd.dao.EmrDao in project herd by FINRAOS.
the class EmrHelperTest method testGetActiveEmrClusterIdNoIdSpecifiedAssertErrorWhenClusterDoesNotExist.
@Test
public void testGetActiveEmrClusterIdNoIdSpecifiedAssertErrorWhenClusterDoesNotExist() {
EmrDao originalEmrDao = emrHelper.getEmrDao();
EmrDao mockEmrDao = mock(EmrDao.class);
emrHelper.setEmrDao(mockEmrDao);
try {
String emrClusterId = null;
String emrClusterName = "emrClusterName";
when(mockEmrDao.getActiveEmrClusterByName(any(), any())).thenReturn(null);
try {
emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("The cluster with name \"%s\" does not exist.", emrClusterName), e.getMessage());
}
verify(mockEmrDao).getActiveEmrClusterByName(eq(emrClusterName), any());
verifyNoMoreInteractions(mockEmrDao);
} finally {
emrHelper.setEmrDao(originalEmrDao);
}
}
use of org.finra.herd.dao.EmrDao in project herd by FINRAOS.
the class EmrHelperTest method testGetActiveEmrClusterIdAssertReturnActualClusterIdWhenClusterIdSpecifiedAndClusterStateActiveAndNameMatch.
@Test
public void testGetActiveEmrClusterIdAssertReturnActualClusterIdWhenClusterIdSpecifiedAndClusterStateActiveAndNameMatch() {
EmrDao originalEmrDao = emrHelper.getEmrDao();
EmrDao mockEmrDao = mock(EmrDao.class);
emrHelper.setEmrDao(mockEmrDao);
try {
String emrClusterId = "emrClusterId";
String emrClusterName = "emrClusterName";
String expectedEmrClusterId = "expectedEmrClusterId";
when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(emrClusterName).withStatus(new ClusterStatus().withState(ClusterState.RUNNING)));
assertEquals(expectedEmrClusterId, emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null));
verify(mockEmrDao).getEmrClusterById(eq(emrClusterId.trim()), any());
verifyNoMoreInteractions(mockEmrDao);
} finally {
emrHelper.setEmrDao(originalEmrDao);
}
}
use of org.finra.herd.dao.EmrDao in project herd by FINRAOS.
the class EmrHelperTest method testGetActiveEmrClusterIdAssertParametersCaseIgnored.
@Test
public void testGetActiveEmrClusterIdAssertParametersCaseIgnored() {
EmrDao originalEmrDao = emrHelper.getEmrDao();
EmrDao mockEmrDao = mock(EmrDao.class);
emrHelper.setEmrDao(mockEmrDao);
try {
String emrClusterId = "emrClusterId";
String emrClusterName = "emrClusterName";
String expectedEmrClusterId = "expectedEmrClusterId";
when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(emrClusterName).withStatus(new ClusterStatus().withState(ClusterState.RUNNING)));
assertEquals(expectedEmrClusterId, emrHelper.getActiveEmrClusterId(StringUtils.upperCase(emrClusterId), StringUtils.upperCase(emrClusterName), null));
verify(mockEmrDao).getEmrClusterById(eq(StringUtils.upperCase(emrClusterId)), any());
verifyNoMoreInteractions(mockEmrDao);
} finally {
emrHelper.setEmrDao(originalEmrDao);
}
}
Aggregations