@Test public void test_setFieldAttribute_normal() { Map<String, String> attributes = new HashMap<>(); processor.setFieldAttribute(attributes, "test.", "abc", "123", -1); processor.setFieldAttribute(attributes, "test.", "xyz", null, -1); processor.setFieldAttribute(attributes, "test.", "xyz", " ", 1); processor.setFieldAttribute(attributes, " test.", "xyz ", null, 2); processor.setFieldAttribute(attributes, "test@", "xyz", null, 3); processor.setFieldAttribute(attributes, "test.", "zzz", "ZZzzz... ", -1); processor.setFieldAttribute(attributes, "test.aaa", null, "none", -1); processor.setFieldAttribute(attributes, "orchsym.", "abc", "xyz", 0); processor.setFieldAttribute(attributes, "orchsym.", "abc", 123, 8); processor.setFieldAttribute(attributes, "orchsym.", "abc", 1.1, 10); processor.setFieldAttribute(attributes, "orchsym.", "abc", Boolean.TRUE, 20); processor.setFieldAttribute(attributes, "orchsym.", "abc", new byte[] { (byte) 'x', (byte) 'y', (byte) 'z' }, 30); processor.setFieldAttribute(attributes, "orchsym.", "abc", new char[] { (char) '1', (char) '2', (char) '3' }, 40); assertThat(attributes, hasEntry("test.abc", "123")); assertThat(attributes, hasEntry("test.xyz", "")); assertThat(attributes, hasEntry("test.xyz.1", " ")); assertThat(attributes, hasEntry("test.xyz.2", "")); assertThat(attributes, hasEntry("test@.xyz.3", "")); assertThat(attributes, hasEntry("test.zzz", "ZZzzz... ")); assertThat(attributes, hasEntry("test.aaa", "none")); assertThat(attributes, hasEntry("orchsym.abc.0", "xyz")); assertThat(attributes, hasEntry("orchsym.abc.8", "123")); assertThat(attributes, hasEntry("orchsym.abc.10", "1.1")); assertThat(attributes, hasEntry("orchsym.abc.20", "true")); assertThat(attributes, hasEntry("orchsym.abc.30", "xyz")); assertThat(attributes, hasEntry("orchsym.abc.40", "123")); }
protected void setFieldAttribute(Map<String, String> attributes, String attrPrefix, String fieldName, Object data, int index) { final String name = getAttributeName(attrPrefix, fieldName, index); if (data instanceof byte[]) { data = new String((byte[]) data, StandardCharsets.UTF_8); } if (data instanceof char[]) { data = String.valueOf((char[]) data); } attributes.put(name, Objects.toString(data, "")); }
AbstractExtractToAttributesProcessor extends AbstractProcessor { protected void setFieldAttribute(Map<String, String> attributes, String attrPrefix, String fieldName, Object data, int index) { final String name = getAttributeName(attrPrefix, fieldName, index); if (data instanceof byte[]) { data = new String((byte[]) data, StandardCharsets.UTF_8); } if (data instanceof char[]) { data = String.valueOf((char[]) data); } attributes.put(name, Objects.toString(data, "")); } }
AbstractExtractToAttributesProcessor extends AbstractProcessor { protected void setFieldAttribute(Map<String, String> attributes, String attrPrefix, String fieldName, Object data, int index) { final String name = getAttributeName(attrPrefix, fieldName, index); if (data instanceof byte[]) { data = new String((byte[]) data, StandardCharsets.UTF_8); } if (data instanceof char[]) { data = String.valueOf((char[]) data); } attributes.put(name, Objects.toString(data, "")); }  }
AbstractExtractToAttributesProcessor extends AbstractProcessor { protected void setFieldAttribute(Map<String, String> attributes, String attrPrefix, String fieldName, Object data, int index) { final String name = getAttributeName(attrPrefix, fieldName, index); if (data instanceof byte[]) { data = new String((byte[]) data, StandardCharsets.UTF_8); } if (data instanceof char[]) { data = String.valueOf((char[]) data); } attributes.put(name, Objects.toString(data, "")); }  @Override Set<Relationship> getRelationships(); @OnScheduled void onScheduled(final ProcessContext context); @Override void onTrigger(ProcessContext context, ProcessSession session); }
AbstractExtractToAttributesProcessor extends AbstractProcessor { protected void setFieldAttribute(Map<String, String> attributes, String attrPrefix, String fieldName, Object data, int index) { final String name = getAttributeName(attrPrefix, fieldName, index); if (data instanceof byte[]) { data = new String((byte[]) data, StandardCharsets.UTF_8); } if (data instanceof char[]) { data = String.valueOf((char[]) data); } attributes.put(name, Objects.toString(data, "")); }  @Override Set<Relationship> getRelationships(); @OnScheduled void onScheduled(final ProcessContext context); @Override void onTrigger(ProcessContext context, ProcessSession session); static final Relationship REL_SUCCESS; static final Relationship REL_FAILURE; }