Platform SDK
5.6
5.6
  • Attivio Platform SDK 5.6.3
  • Module SDK
  • Service Factory
    • Creating a Custom Service
    • Testing with the ServiceFactory
  • Custom Executables
  • Components
    • Writing Components
    • Testing Components
  • Scanners
    • Basic Custom Scanner Example
    • Incremental Scanner Example
    • Principal Scanner Example
    • Glossary
  • 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

PreviousWriting ComponentsNextScanners

Last updated 5 years ago

Was this helpful?

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.

The archetype generation referenced on the 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

IngestDocument doc = new IngestDocument("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"));
Module SDK