StephenOTT / STIX-Java

STIX 2.x Java Library
MIT License
27 stars 13 forks source link

More unit testing #86

Closed anlklsim closed 5 years ago

anlklsim commented 5 years ago

wanted to test how to open a pull request on a different branch of the original

StephenOTT commented 5 years ago

@anlklsim take a look at the https://github.com/StephenOTT/STIX-Java/tree/feature/unit-testing/src/test/groovy/stix/sdo files. As you should not have to build the specs by hand. The StixMockDataGenerator.groovy has the mock generators in them, and the Spec file becomes a minimal template that just has a few names changed.

anlklsim commented 5 years ago

I will look at those, just wanted to see if I could read in the large threat report example that I had before moving on.

StephenOTT commented 5 years ago

+1

anlklsim commented 5 years ago

I discovered that the sophistication attribute of ThreatActorSdo should have been an Optional and not a Set. That was a cut/paste error on my side when copying from my old project. I do like testing with real examples, but I see the utility of testing with generated cases.

StephenOTT commented 5 years ago

We can create base single use JSON files that represent a happy standard for each SDO with all of the nested objects. But in order to have coverage on all of the various constraints and business rules, the generated objects are needed. Otherwise we will be handling a huge number of manual json files. :)

StephenOTT commented 5 years ago

@anlklsim also note you need to update the JsonInclude annotation on the sophistication to: @JsonInclude(value = NON_EMPTY, content= NON_EMPTY)

StephenOTT commented 5 years ago

@anlklsim see the updates to the https://github.com/StephenOTT/STIX-Java/pull/79

All of the SDOs including Report and Observed Data have been added. Initial issues fixed. If you want to create baseline JSON files for each SDO that represent a basic happy version of JSON, we can create a set of tests for these.

Observed Data does not support some of the _ref / _refs, and does not support COO extensions at the moment.

SDOs do not have SRO relationships or data-markings turned on either.

The Final big part is to setup a higher up generator that can generate a bundle of objects with actual relationships/references to other UUIDs in the bundle. Generally a low priority imo.

Bundle creation will basically be the same setup as creating a Report SDO. Will tackle that likely next week.

StephenOTT commented 5 years ago

@anlklsim check out latest updates. Lots of good stuff :)

StephenOTT commented 5 years ago

closing as it has become stale.