Platform SDK
4.4
4.4
  • Attivio Platform SDK 4.4
  • Module SDK
  • Client SDK
  • Components
    • Writing Components
    • Testing Components
  • License
Powered by GitBook
On this page
  • Create the component
  • Configure your component
  • Optionally "start" your component
  • Create a sample document to use in your test
  • Process the document with your component
  • Assert conditions on the document

Was this helpful?

  1. Components

Testing Components

It is important to write focused and concise unit tests for your custom components. Attivio provides a number of testing utilities and mock implementations to make writing good unit tests simple. This archetype generation referenced by the README page provides examples of the techniques described here.

Create the component

MyComponent component = new MyComponent();

Configure your component

// some example properties
component.setRate(20.3);
component.setLabel("label");

Optionally "start" your component

If your component uses any of the lifecycle or miscellaneous mix-ins, there is a test utility that will call them and set them up with appropriate mock implementations as needed:

SdkTestUtils.startTransformer(component);

Create a sample document to use in your test

AttivioDocument doc = new AttivioDocument("doc1");
doc.setField("text", "some text");
doc.setField("cost", 2800.23);

Process the document with your component

SdkTestUtils.processDocument(doc, component);

Assert conditions on the document

Assert.assertTrue(doc.containsField("newField"));
PreviousWriting ComponentsNextLicense

Last updated 5 years ago

Was this helpful?