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;
}
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;
}
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)));
}
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();
}
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();
}
Aggregations