### Question:
FactCreateHandler { public List<Subject> resolveSubjects(List<String> acl) throws InvalidArgumentException { if (CollectionUtils.isEmpty(acl)) return Collections.emptyList(); List<Subject> result = new ArrayList<>(); InvalidArgumentException unresolved = new InvalidArgumentException(); for (int i = 0; i < acl.size(); i++) { Subject subject; String idOrName = acl.get(i); if (StringUtils.isUUID(idOrName)) { subject = subjectResolver.resolveSubject(UUID.fromString(idOrName)); } else { subject = subjectResolver.resolveSubject(idOrName); } if (subject != null) { result.add(subject); } else { unresolved.addValidationError("Subject does not exist.", "subject.not.exist", String.format("acl[%d]", i), idOrName); } } if (unresolved.hasErrors()) throw unresolved; return result; } @Inject  FactCreateHandler(TiSecurityContext securityContext,
                           SubjectResolver subjectResolver,
                           OrganizationResolver organizationResolver,
                           OriginManager originManager,
                           ValidatorFactory validatorFactory,
                           ObjectFactDao objectFactDao,
                           FactResponseConverter factResponseConverter,
                           TriggerContext triggerContext); Organization resolveOrganization(String idOrName, OriginEntity fallback); OriginEntity resolveOrigin(String idOrName); List<Subject> resolveSubjects(List<String> acl); FactRecord.AccessMode resolveAccessMode(FactRecord referencedFact, AccessMode requestedAccessMode); Fact saveFact(FactRecord fact, String comment, List<UUID> subjectIds); void assertValidFactValue(FactTypeEntity type, String value);  }### Answer:
@Test public void testResolveSubjectsWithoutAcl() throws Exception { assertNotNull(handler.resolveSubjects(null)); assertNotNull(handler.resolveSubjects(new ArrayList<>())); }
@Test public void testResolveSubjectsByIdOrName() throws Exception { when(subjectResolver.resolveSubject(isA(UUID.class))).thenReturn(Subject.builder().build()); when(subjectResolver.resolveSubject(isA(String.class))).thenReturn(Subject.builder().build()); List<String> acl = list(UUID.randomUUID().toString(), "name", UUID.randomUUID().toString()); assertEquals(acl.size(), handler.resolveSubjects(acl).size()); verify(subjectResolver, times(2)).resolveSubject(isA(UUID.class)); verify(subjectResolver).resolveSubject("name"); }
@Test public void testResolveSubjectsFailsOnUnresolved() { when(subjectResolver.resolveSubject(isA(String.class))).thenReturn(Subject.builder().build()); List<String> acl = list(UUID.randomUUID().toString(), "name", UUID.randomUUID().toString()); InvalidArgumentException ex = assertThrows(InvalidArgumentException.class, () -> handler.resolveSubjects(acl)); assertEquals(set("acl[0]", "acl[2]"), set(ex.getValidationErrors(), InvalidArgumentException.ValidationError::getProperty)); verify(subjectResolver, times(2)).resolveSubject(isA(UUID.class)); verify(subjectResolver).resolveSubject("name"); }