/******************************************************************************************************************* * * ******************************************************************************************************************/ public ContextSampler (final @Nonnull Object owner) { contexts = Collections.unmodifiableList(contextManager.getContexts()); if (log.isTraceEnabled()) { log.trace(">>>> contexts for {} at construction time: {}", shortId(owner), shortIds(contexts)); } }
@Nonnull public static String shortIds (final @Nonnull Iterable<Object> objects) { final StringBuilder result = new StringBuilder(); String separator = ""; for (final Object object : objects) { result.append(separator).append(shortId(object)); separator = ", "; } return "[" + result.toString() + "]"; } }
@Override @Nonnull public PresentationModel run() { final List<Object> roles = resolveRoles(datum, rolesOrFactories); roles.add(new DefaultSimpleComposite<>(pmFinder)); log.trace(">>>> roles for {}: {}", shortId(datum), shortIds(roles)); return defaultPresentationModelFactory.createPresentationModel(datum, roles.toArray()); } });
/******************************************************************************************************************* * ******************************************************************************************************************/ @Test(dataProvider = "ownersAndRoleImplementations") public void must_correctly_find_roles (final @Nonnull Object owner, final @Nonnull Class<?> roleClass, final @Nonnull List<?> expectedRoles) throws NotFoundException { // given when(contextManager.findContextOfType(eq(Context1.class))).thenThrow(new NotFoundException()); when(contextManager.findContextOfType(eq(Context2.class))).thenReturn(context2); final UnderTest underTest = new UnderTest(); registerMockRoles(underTest); underTest.registerBean(bean1); underTest.registerBean(bean2); underTest.scan(asList(RI1A.class, RI1B.class, RI1C.class, RI2A.class, RI2B.class, RI2C.class, RI3A.class, RI3B.class, RI3C.class)); // when final List<?> actualRoles = underTest.findRoles(owner, roleClass); // then final String s = String.format("owner: %s role: %s", shortId(owner), shortName(roleClass)); assertListEquals(s, actualRoles, expectedRoles); }
throws T final String taskId = shortId(task); final String contextIds = shortIds(contexts);
final @Nonnull Class<ROLE_TYPE> roleType) log.trace("findRoles({}, {})", shortId(datum), shortName(roleType)); final Class<?> datumType = findTypeOf(datum); final List<ROLE_TYPE> roles = new ArrayList<>();