### Question:
SecurityEventBuilder { public SecurityEvent createSecurityEvent(String loggingClass, URI requestUri, String slMessage, boolean defaultTargetToUserEdOrg) { return createSecurityEvent( loggingClass, requestUri, slMessage, null, null,null, null, defaultTargetToUserEdOrg); } SecurityEventBuilder(); SecurityEvent createSecurityEvent(String loggingClass, URI requestUri, String slMessage, boolean defaultTargetToUserEdOrg); SecurityEvent createSecurityEvent(String loggingClass, URI requestUri, String slMessage,
                                             Entity explicitRealmEntity, String entityType, String[] entityIds); SecurityEvent createSecurityEvent(String loggingClass, URI requestUri, String slMessage,
                                             Entity explicitRealmEntity, String entityType, Set<Entity> entities); SecurityEvent createSecurityEvent(String loggingClass, URI explicitUri, String slMessage, SLIPrincipal explicitPrincipal, String clientId, Entity explicitRealmEntity,
                                             Set<String> targetEdOrgs, boolean defaultTargetToUserEdOrg); CallingApplicationInfoProvider getCallingApplicationInfoProvider(); void setCallingApplicationInfoProvider(CallingApplicationInfoProvider callingApplicationInfoProvider);  }### Answer:
@Test public void testCreateSecurityEventUsingDefaultTargetToUserEdOrg() { SecurityEvent se = builder.createSecurityEvent(this.getClass().getName(), URI.create(ONE_PART_URI), LOG_MESSAGE, true); Assert.assertTrue(se.getActionUri().equals(ONE_PART_URI)); Assert.assertTrue(se.getLogMessage().equals(LOG_MESSAGE)); Assert.assertTrue(se.getUserEdOrg().equals(REALM_EDORG_STATEID)); Assert.assertTrue(se.getTargetEdOrgList().contains(se.getUserEdOrg())); }
@Test public void testCreateSecurityEventFromEntityIds() { prepareTargetEdOrgMocks(); String[] entityIds = {SECTION_ENTITY_ID, SECTION_ENTITY2_ID}; SecurityEvent se = builder.createSecurityEvent(this.getClass().getName(), URI.create(ONE_PART_URI), LOG_MESSAGE, null, EntityNames.SECTION, entityIds); Assert.assertTrue(se.getActionUri().equals(ONE_PART_URI)); Assert.assertTrue(se.getLogMessage().equals(LOG_MESSAGE)); Assert.assertTrue(se.getUserEdOrg().equals(REALM_EDORG_STATEID)); Assert.assertTrue(containsTheSame(se.getTargetEdOrgList(), Arrays.asList(EDORG_STATEID, EDORG2_STATEID))); }
@Test public void testCreateSecurityFromEventEntities() { prepareTargetEdOrgMocks(); Set<Entity> entities = new HashSet<Entity>(); entities.add(section1); entities.add(section2); SecurityEvent se = builder.createSecurityEvent(this.getClass().getName(), URI.create(ONE_PART_URI), LOG_MESSAGE, null, EntityNames.SECTION, entities); Assert.assertTrue(se.getActionUri().equals(ONE_PART_URI)); Assert.assertTrue(se.getLogMessage().equals(LOG_MESSAGE)); Assert.assertTrue(se.getUserEdOrg().equals(REALM_EDORG_STATEID)); Assert.assertTrue(containsTheSame(se.getTargetEdOrgList(), Arrays.asList(EDORG_STATEID, EDORG2_STATEID))); }