AssignValueImplementer implements RuleActionApplier { @Override public TrackerBundle executeActions( TrackerBundle bundle ) { Map<String, List<RuleEffect>> enrollmentEffects = getEffects( bundle.getEnrollmentRuleEffects() ); enrollmentEffects .entrySet() .stream() .forEach( e -> getTrackedEntityFromEnrollment( bundle, e.getKey() ) .ifPresent( tei -> setTeiAttribute( tei, e.getValue() ) ) ); Map<String, List<RuleEffect>> eventEffects = getEffects( bundle.getEventRuleEffects() ); eventEffects .entrySet() .stream() .forEach( e -> getEvent( bundle, e.getKey() ) .ifPresent( tei -> setDataElement( tei, e.getValue() ) ) ); return bundle; }  @Override Class getActionClass(); @Override TrackerBundle executeActions( TrackerBundle bundle );  }
@Test public void testAssignAttributeValueForEnrollment() throws IOException { TrackerBundleParams bundleParams = createBundleFromJson( "tracker/enrollment.json" ); TrackerBundle trackerBundle = trackerBundleService.create( bundleParams ); trackerBundle = trackerBundleService.runRuleEngine( trackerBundle ); TrackerBundle updatedBundle = implementerToTest.executeActions( trackerBundle ); Enrollment enrollment = updatedBundle.getEnrollments().get( 0 ); assertNotNull( enrollment ); Attribute attribute = trackerBundle.getTrackedEntities().get( 0 ).getAttributes().stream() .filter( a -> a.getAttribute().equals( "sYn3tkL3XKa" ) ).findAny().get(); assertEquals( TEI_ATTRIBUTE_NEW_VALUE, attribute.getValue() ); }