Search in sources :

Example 1 with ApiEventAttribute

use of com.cloudera.api.swagger.model.ApiEventAttribute in project knox by apache.

the class PollingConfigurationAnalyzerTest method doTestStartEvent.

private void doTestStartEvent(final ApiEventCategory category) {
    final String clusterName = "My Cluster";
    final String serviceType = NameNodeServiceModelGenerator.SERVICE_TYPE;
    final String service = NameNodeServiceModelGenerator.SERVICE;
    List<ApiEventAttribute> apiEventAttrs = new ArrayList<>();
    apiEventAttrs.add(createEventAttribute("CLUSTER", clusterName));
    apiEventAttrs.add(createEventAttribute("SERVICE_TYPE", serviceType));
    apiEventAttrs.add(createEventAttribute("SERVICE", service));
    ApiEvent apiEvent = createApiEvent(category, apiEventAttrs, null);
    PollingConfigurationAnalyzer.StartEvent restartEvent = new PollingConfigurationAnalyzer.StartEvent(apiEvent);
    assertNotNull(restartEvent);
    assertEquals(clusterName, restartEvent.getClusterName());
    assertEquals(serviceType, restartEvent.getServiceType());
    assertEquals(service, restartEvent.getService());
    assertNotNull(restartEvent.getTimestamp());
}
Also used : ApiEventAttribute(com.cloudera.api.swagger.model.ApiEventAttribute) ApiEvent(com.cloudera.api.swagger.model.ApiEvent) ArrayList(java.util.ArrayList)

Example 2 with ApiEventAttribute

use of com.cloudera.api.swagger.model.ApiEventAttribute in project knox by apache.

the class PollingConfigurationAnalyzerTest method createEventAttribute.

private ApiEventAttribute createEventAttribute(final String name, final String value) {
    ApiEventAttribute attr = EasyMock.createNiceMock(ApiEventAttribute.class);
    EasyMock.expect(attr.getName()).andReturn(name).anyTimes();
    EasyMock.expect(attr.getValues()).andReturn(Collections.singletonList(value)).anyTimes();
    EasyMock.replay(attr);
    return attr;
}
Also used : ApiEventAttribute(com.cloudera.api.swagger.model.ApiEventAttribute)

Example 3 with ApiEventAttribute

use of com.cloudera.api.swagger.model.ApiEventAttribute in project knox by apache.

the class PollingConfigurationAnalyzerTest method testEventWithoutCommandOrCommandStatus.

/**
 * KNOX-2350
 */
@Test
public void testEventWithoutCommandOrCommandStatus() {
    final String clusterName = "Cluster T";
    // Simulate an event w/o COMMAND and/or COMMAND_STATUS attributes
    final List<ApiEventAttribute> revisionEventAttrs = new ArrayList<>();
    revisionEventAttrs.add(createEventAttribute("CLUSTER", clusterName));
    revisionEventAttrs.add(createEventAttribute("SERVICE_TYPE", HiveOnTezServiceModelGenerator.SERVICE_TYPE));
    revisionEventAttrs.add(createEventAttribute("SERVICE", HiveOnTezServiceModelGenerator.SERVICE));
    revisionEventAttrs.add(createEventAttribute("REVISION", "215"));
    revisionEventAttrs.add(createEventAttribute("EVENTCODE", "EV_REVISION_CREATED"));
    final ApiEvent revisionEvent = createApiEvent(ApiEventCategory.AUDIT_EVENT, revisionEventAttrs, null);
    doTestEventWithoutConfigChange(revisionEvent, clusterName);
}
Also used : ApiEventAttribute(com.cloudera.api.swagger.model.ApiEventAttribute) ApiEvent(com.cloudera.api.swagger.model.ApiEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ApiEventAttribute (com.cloudera.api.swagger.model.ApiEventAttribute)3 ApiEvent (com.cloudera.api.swagger.model.ApiEvent)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)1