Search in sources :

Example 1 with EmrClusterDefinitionKeys

use of org.finra.herd.model.api.xml.EmrClusterDefinitionKeys in project herd by FINRAOS.

the class EmrClusterDefinitionServiceImpl method getEmrClusterDefinitions.

@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public EmrClusterDefinitionKeys getEmrClusterDefinitions(String namespace) {
    // Validate the namespace.
    Assert.hasText(namespace, "A namespace must be specified.");
    // Retrieve and return the list of EMR cluster definition keys.
    EmrClusterDefinitionKeys emrClusterDefinitionKeys = new EmrClusterDefinitionKeys();
    emrClusterDefinitionKeys.getEmrClusterDefinitionKeys().addAll(emrClusterDefinitionDao.getEmrClusterDefinitionsByNamespace(namespace.trim()));
    return emrClusterDefinitionKeys;
}
Also used : EmrClusterDefinitionKeys(org.finra.herd.model.api.xml.EmrClusterDefinitionKeys) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 2 with EmrClusterDefinitionKeys

use of org.finra.herd.model.api.xml.EmrClusterDefinitionKeys in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionsLowerCaseParameters.

@Test
public void testGetEmrClusterDefinitionsLowerCaseParameters() throws Exception {
    // Create and persist an EMR cluster definition entity.
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    // Create an EMR cluster definition key.
    EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Retrieve EMR cluster definition keys by passing namespace parameter value in lowercase.
    assertEquals(new EmrClusterDefinitionKeys(Arrays.asList(emrClusterDefinitionKey)), emrClusterDefinitionService.getEmrClusterDefinitions(NAMESPACE.toLowerCase()));
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionKeys(org.finra.herd.model.api.xml.EmrClusterDefinitionKeys) Test(org.junit.Test)

Example 3 with EmrClusterDefinitionKeys

use of org.finra.herd.model.api.xml.EmrClusterDefinitionKeys in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionsUpperCaseParameters.

@Test
public void testGetEmrClusterDefinitionsUpperCaseParameters() throws Exception {
    // Create and persist an EMR cluster definition entity.
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    // Create an EMR cluster definition key.
    EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Retrieve EMR cluster definition keys by passing namespace parameter value in uppercase.
    assertEquals(new EmrClusterDefinitionKeys(Arrays.asList(emrClusterDefinitionKey)), emrClusterDefinitionService.getEmrClusterDefinitions(NAMESPACE.toUpperCase()));
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionKeys(org.finra.herd.model.api.xml.EmrClusterDefinitionKeys) Test(org.junit.Test)

Example 4 with EmrClusterDefinitionKeys

use of org.finra.herd.model.api.xml.EmrClusterDefinitionKeys in project herd by FINRAOS.

the class EmrClusterDefinitionRestControllerTest method testGetEmrClusterDefinitions.

@Test
public void testGetEmrClusterDefinitions() throws Exception {
    // Create an EMR cluster definition keys.
    EmrClusterDefinitionKeys emrClusterDefinitionKeys = new EmrClusterDefinitionKeys(Arrays.asList(new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME)));
    // Mock the external calls.
    when(emrClusterDefinitionService.getEmrClusterDefinitions(NAMESPACE)).thenReturn(emrClusterDefinitionKeys);
    // Call the method under test.
    EmrClusterDefinitionKeys result = emrClusterDefinitionRestController.getEmrClusterDefinitions(NAMESPACE);
    // Verify the external calls.
    verify(emrClusterDefinitionService).getEmrClusterDefinitions(NAMESPACE);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(emrClusterDefinitionKeys, result);
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionKeys(org.finra.herd.model.api.xml.EmrClusterDefinitionKeys) Test(org.junit.Test)

Example 5 with EmrClusterDefinitionKeys

use of org.finra.herd.model.api.xml.EmrClusterDefinitionKeys in project herd by FINRAOS.

the class EmrClusterDefinitionServiceTest method testGetEmrClusterDefinitionsTrimParameters.

@Test
public void testGetEmrClusterDefinitionsTrimParameters() throws Exception {
    // Create and persist an EMR cluster definition entity.
    emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE), EMR_CLUSTER_DEFINITION_NAME, IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_WITH_CLASSPATH).getInputStream()));
    // Create an EMR cluster definition key.
    EmrClusterDefinitionKey emrClusterDefinitionKey = new EmrClusterDefinitionKey(NAMESPACE, EMR_CLUSTER_DEFINITION_NAME);
    // Retrieve EMR cluster definition keys by passing namespace with leading and trailing whitespace characters.
    assertEquals(new EmrClusterDefinitionKeys(Arrays.asList(emrClusterDefinitionKey)), emrClusterDefinitionService.getEmrClusterDefinitions(addWhitespace(NAMESPACE)));
}
Also used : EmrClusterDefinitionKey(org.finra.herd.model.api.xml.EmrClusterDefinitionKey) EmrClusterDefinitionKeys(org.finra.herd.model.api.xml.EmrClusterDefinitionKeys) Test(org.junit.Test)

Aggregations

EmrClusterDefinitionKeys (org.finra.herd.model.api.xml.EmrClusterDefinitionKeys)6 EmrClusterDefinitionKey (org.finra.herd.model.api.xml.EmrClusterDefinitionKey)5 Test (org.junit.Test)5 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1