### Question:
InputEntityDecorators { public static Decorator additiveLabels( final String[] labelNamesToAdd ) { if ( labelNamesToAdd == null || labelNamesToAdd.length == 0 ) { return NO_DECORATOR; } return node -> new AdditiveLabelsDecorator( node, labelNamesToAdd ); } private  InputEntityDecorators(); static Decorator additiveLabels( final String[] labelNamesToAdd ); static Decorator defaultRelationshipType( final String defaultType ); static Decorator decorators( final Decorator... decorators ); static final Decorator NO_DECORATOR; }### Answer:
@Test public void shouldAddLabelsToNodeWithoutLabels() throws Exception { String[] toAdd = new String[] {"Add1", "Add2"}; InputEntityVisitor node = additiveLabels( toAdd ).apply( entity ); node( node, "source", 1, 0, "id", NO_PROPERTIES, null, NO_LABELS, null ); assertArrayEquals( toAdd, entity.labels() ); }
@Test public void shouldAddMissingLabels() throws Exception { String[] toAdd = new String[] {"Add1", "Add2"}; InputEntityVisitor node = additiveLabels( toAdd ).apply( entity ); String[] nodeLabels = new String[] {"SomeOther"}; node( node, "source", 1, 0, "id", NO_PROPERTIES, null, nodeLabels, null ); assertEquals( asSet( ArrayUtil.union( toAdd, nodeLabels ) ), asSet( entity.labels() ) ); }
@Test public void shouldNotTouchLabelsIfNodeHasLabelFieldSet() throws Exception { String[] toAdd = new String[] {"Add1", "Add2"}; InputEntityVisitor node = additiveLabels( toAdd ).apply( entity ); long labelField = 123L; node( node, "source", 1, 0, "id", NO_PROPERTIES, null, null, labelField ); assertEquals( 0, entity.labels().length ); assertEquals( labelField, entity.labelField ); }