Skip to content

Commit

Permalink
Merge pull request #16 from sentrysoftware/feature/issue-14-update-co…
Browse files Browse the repository at this point in the history
…nstant-references

Issue #14: Update-constant-references
  • Loading branch information
NassimBtk authored Feb 9, 2024
2 parents 16630ff + ec1dcec commit e058534
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
*/
public class ConstantsProcessor extends AbstractNodeProcessor {

/**
* Constants Pattern
*/
private static final String CONSTANTS_REFERENCE_PATTERN = "${constant::%s}";

/**
* Constructs a ConstantsProcessor without a next processor.
*/
Expand All @@ -53,7 +58,7 @@ public JsonNode processNode(final JsonNode node) {
final Map<String, String> replacements = new HashMap<>();
for (String key : constantKeys) {
final JsonNode child = constantsNode.get(key);
replacements.put(key, child.asText());
replacements.put(String.format(CONSTANTS_REFERENCE_PATTERN, key), child.asText());
}

final UnaryOperator<String> updater = value -> performReplacements(replacements, value);
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/connector/MIB2-header/MIB2-header.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ connector:
criteria:
# Criteria(1): there must be something in the ifTable SNMP Table
- type: snmpGetNext
oid: _OID
oid: ${constant::_OID}

monitors:
network:
Expand All @@ -23,7 +23,7 @@ monitors:
# Source(1) = ifTable SNMP Table
# PortID;Description;TypeCode;MacAddress;AdminStatus;
type: snmpTable
oid: _OID
oid: ${constant::_OID}
selectColumns: "ID,2,3,6,7"
computes:
# Keep only ports whose administrative status is 'up'
Expand Down Expand Up @@ -66,7 +66,7 @@ monitors:
# Source(1) = ifTable SNMP Table
# PortID;Description;Speed;OperationalStatus;ReceivedBytes;ReceivedUnicastPackets;ReceivedNonUnicastPackets;ReceivedErrors;TransmittedBytes;TransmittedUnicastPackets;TransmittedNonUnicastPackets;TransmittedErrors;
type: snmpTable
oid: _OID
oid: ${constant::_OID}
selectColumns: "ID,2,5,8,10,11,12,14,16,17,18,20"
computes:
# Duplicate Status twice
Expand Down

0 comments on commit e058534

Please sign in to comment.