Search in sources :

Example 1 with LogstashAttributeValue

use of org.opensearch.dataprepper.logstash.model.LogstashAttributeValue in project data-prepper by opensearch-project.

the class GrokLogstashPluginAttributesMapperTest method preparePatternDefinitionsLogstashAttribute.

private LogstashAttribute preparePatternDefinitionsLogstashAttribute(final Map<String, String> patternDefinitions) {
    final LogstashAttribute logstashAttribute = mock(LogstashAttribute.class);
    final LogstashAttributeValue logstashAttributeValue = mock(LogstashAttributeValue.class);
    when(logstashAttributeValue.getAttributeValueType()).thenReturn(HASH);
    when(logstashAttributeValue.getValue()).thenReturn(patternDefinitions);
    when(logstashAttribute.getAttributeName()).thenReturn(LOGSTASH_GROK_PATTERN_DEFINITIONS_ATTRIBUTE_NAME);
    when(logstashAttribute.getAttributeValue()).thenReturn(logstashAttributeValue);
    return logstashAttribute;
}
Also used : LogstashAttributeValue(org.opensearch.dataprepper.logstash.model.LogstashAttributeValue) LogstashAttribute(org.opensearch.dataprepper.logstash.model.LogstashAttribute)

Example 2 with LogstashAttributeValue

use of org.opensearch.dataprepper.logstash.model.LogstashAttributeValue in project data-prepper by opensearch-project.

the class OpenSearchPluginAttributesMapperTest method createLogstashIndexAttribute.

private LogstashAttribute createLogstashIndexAttribute(final String indexAttributeValue) {
    final LogstashAttribute logstashAttribute = mock(LogstashAttribute.class);
    final LogstashAttributeValue logstashAttributeValue = mock(LogstashAttributeValue.class);
    when(logstashAttribute.getAttributeName()).thenReturn(LOGSTASH_OPENSEARCH_INDEX_ATTRIBUTE_NAME);
    when(logstashAttribute.getAttributeValue()).thenReturn(logstashAttributeValue);
    when(logstashAttributeValue.getAttributeValueType()).thenReturn(LogstashValueType.STRING);
    when(logstashAttributeValue.getValue()).thenReturn(indexAttributeValue);
    return logstashAttribute;
}
Also used : LogstashAttributeValue(org.opensearch.dataprepper.logstash.model.LogstashAttributeValue) LogstashAttribute(org.opensearch.dataprepper.logstash.model.LogstashAttribute)

Example 3 with LogstashAttributeValue

use of org.opensearch.dataprepper.logstash.model.LogstashAttributeValue in project data-prepper by opensearch-project.

the class OpenSearchPluginAttributesMapperTest method convert_emptyString_indexAttribute_to_return_pluginSettings_with_no_index_key.

@Test
void convert_emptyString_indexAttribute_to_return_pluginSettings_with_no_index_key() {
    final LogstashAttribute logstashAttribute = mock(LogstashAttribute.class);
    final LogstashAttributeValue logstashAttributeValue = mock(LogstashAttributeValue.class);
    when(logstashAttribute.getAttributeName()).thenReturn(UUID.randomUUID().toString());
    when(logstashAttribute.getAttributeValue()).thenReturn(logstashAttributeValue);
    when(logstashAttributeValue.getAttributeValueType()).thenReturn(LogstashValueType.STRING);
    when(logstashAttributeValue.getValue()).thenReturn(UUID.randomUUID().toString());
    final LogstashAttributesMappings logstashAttributesMappings = mock(LogstashAttributesMappings.class);
    when(logstashAttributesMappings.getMappedAttributeNames()).thenReturn(Collections.emptyMap());
    final List<PluginModel> actualPluginModel = createObjectUnderTest().mapAttributes(Collections.singletonList(logstashAttribute), logstashAttributesMappings);
    assertThat(actualPluginModel, Matchers.notNullValue());
    assertThat(actualPluginModel.size(), Matchers.equalTo(1));
    assertThat(actualPluginModel.get(0), Matchers.notNullValue());
    assertThat(actualPluginModel.get(0).getPluginSettings().size(), equalTo(0));
    assertThat(actualPluginModel.get(0).getPluginSettings(), not(hasKey(DATA_PREPPER_OPENSEARCH_INDEX_ATTRIBUTE)));
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) LogstashAttributeValue(org.opensearch.dataprepper.logstash.model.LogstashAttributeValue) LogstashAttribute(org.opensearch.dataprepper.logstash.model.LogstashAttribute) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with LogstashAttributeValue

use of org.opensearch.dataprepper.logstash.model.LogstashAttributeValue in project data-prepper by opensearch-project.

the class TestDataProvider method attributeWithHashTypeValueData.

public static LogstashAttribute attributeWithHashTypeValueData() {
    Map<String, Object> values = new LinkedHashMap<>();
    values.put(TestDataProvider.RANDOM_STRING_1, TestDataProvider.RANDOM_STRING_2);
    LogstashAttributeValue logstashAttributeValue = LogstashAttributeValue.builder().attributeValueType(LogstashValueType.HASH).value(values).build();
    return LogstashAttribute.builder().attributeName(TestDataProvider.RANDOM_STRING_1).attributeValue(logstashAttributeValue).build();
}
Also used : LogstashAttributeValue(org.opensearch.dataprepper.logstash.model.LogstashAttributeValue) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with LogstashAttributeValue

use of org.opensearch.dataprepper.logstash.model.LogstashAttributeValue in project data-prepper by opensearch-project.

the class ModelConvertingLogstashVisitor method visitAttribute.

@Override
public Object visitAttribute(final LogstashParser.AttributeContext attributeContext) {
    AttributeInformation info = getAttributeInformation(attributeContext.value());
    if (info == null)
        return null;
    final LogstashAttributeValue logstashAttributeValue = LogstashAttributeValue.builder().attributeValueType(info.logstashValueType).value(info.value).build();
    return LogstashAttribute.builder().attributeName(normalizeText(attributeContext.name().getText())).attributeValue(logstashAttributeValue).build();
}
Also used : LogstashAttributeValue(org.opensearch.dataprepper.logstash.model.LogstashAttributeValue)

Aggregations

LogstashAttributeValue (org.opensearch.dataprepper.logstash.model.LogstashAttributeValue)15 LogstashAttribute (org.opensearch.dataprepper.logstash.model.LogstashAttribute)12 PluginModel (com.amazon.dataprepper.model.configuration.PluginModel)5 Test (org.junit.jupiter.api.Test)5 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DateProcessorConfig (com.amazon.dataprepper.plugins.processor.date.DateProcessorConfig)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1