use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class JobServiceGetJobsTest method testGetJobsWhenJobStatusNullQueryIgnoreStatus.
@SuppressWarnings("unchecked")
@Test
public void testGetJobsWhenJobStatusNullQueryIgnoreStatus() throws Exception {
String namespace = "namespace";
String jobName = "jobName";
JobStatusEnum jobStatus = null;
Set<String> authorizedNamespaces = new HashSet<>(Arrays.asList(namespace));
when(namespaceSecurityHelper.getAuthorizedNamespaces(any())).thenReturn(authorizedNamespaces);
NamespaceEntity namespaceEntity = new NamespaceEntity();
namespaceEntity.setCode(namespace);
when(namespaceDao.getNamespaceByCd(any())).thenReturn(namespaceEntity);
List<JobDefinitionEntity> jobDefinitionEntities = new ArrayList<>();
JobDefinitionEntity jobDefinitionEntity1 = new JobDefinitionEntity();
jobDefinitionEntity1.setActivitiId(namespace + "." + jobName + ":1" + ":1");
jobDefinitionEntities.add(jobDefinitionEntity1);
when(jobDefinitionDao.getJobDefinitionsByFilter(any(Collection.class), any())).thenReturn(jobDefinitionEntities);
when(activitiService.getProcessDefinitionsByIds(any())).thenReturn(asList());
jobServiceImpl.getJobs(namespace, jobName, jobStatus, NO_START_TIME, NO_END_TIME);
// Assert neither status filter was called on the query
verify(activitiService).getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys(isNull(JobStatusEnum.class), any(), any(), any());
verify(activitiService).getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(isNull(JobStatusEnum.class), any(), any(), any());
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testCreateEmrClusterDefinitionEmrClusterDefinitionAlreadyExists.
@Test
public void testCreateEmrClusterDefinitionEmrClusterDefinitionAlreadyExists() throws Exception {
// Create and persist the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create and persist the EMR cluster definition entity.
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Try to perform a create using an already existing EMR cluster definition name.
try {
emrClusterDefinitionService.createEmrClusterDefinition(createEmrClusterDefinitionCreateRequest(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH)));
fail("Should throw an AlreadyExistsException when EMR cluster definition already exists.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create EMR cluster definition with name \"%s\" for namespace \"%s\" because it already exists.", EMR_CLUSTER_DEFINITION_NAME, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionLowerCaseParameters.
@Test
public void testGetEmrClusterDefinitionLowerCaseParameters() throws Exception {
// Create and persist the namespace entity with an uppercase name.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toUpperCase());
// Create and persist the EMR cluster definition entity with an uppercase name.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Get an EMR cluster definition by passing the EMR cluster definition name key parameters in lower case.
EmrClusterDefinitionInformation resultEmrClusterDefinition = emrClusterDefinitionService.getEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase()));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), resultEmrClusterDefinition);
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinitionLowerCaseParameters.
@Test
public void testDeleteEmrClusterDefinitionLowerCaseParameters() throws Exception {
// Create and persist the namespace entity with an uppercase name.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toUpperCase());
// Create and persist the EMR cluster definition entity with an uppercase name.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Validate that this EMR cluster definition exists.
assertNotNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase()));
executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
// Delete this EMR cluster definition by passing the EMR cluster definition name key parameters in lower case.
EmrClusterDefinitionInformation deletedEmrClusterDefinition = emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE.toLowerCase(), EMR_CLUSTER_DEFINITION_NAME.toLowerCase()));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase(), getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), deletedEmrClusterDefinition);
// Ensure that this EMR cluster definition is no longer there.
assertNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE.toUpperCase(), EMR_CLUSTER_DEFINITION_NAME.toUpperCase()));
});
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class EmrClusterDefinitionServiceTest method testDeleteEmrClusterDefinition.
@Test
public void testDeleteEmrClusterDefinition() throws Exception {
// Create and persist the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create and persist the EMR cluster definition entity.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfigurationXml(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH));
// Validate that this EMR cluster definition exists.
assertNotNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME));
executeWithoutLogging(EmrClusterDefinitionServiceImpl.class, () -> {
// Delete this EMR cluster definition.
EmrClusterDefinitionInformation deletedEmrClusterDefinition = emrClusterDefinitionService.deleteEmrClusterDefinition(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME));
// Validate the returned object.
validateEmrClusterDefinition(emrClusterDefinitionEntity.getId(), NAMESPACE, EMR_CLUSTER_DEFINITION_NAME, getTestEmrClusterDefinitionConfiguration(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH), deletedEmrClusterDefinition);
// Ensure that this EMR cluster definition is no longer there.
assertNull(emrClusterDefinitionDao.getEmrClusterDefinitionByAltKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME));
});
}
Aggregations