Example #1
0
  public GetTransUnitListHandler createGetTransUnitListHandlerWithBehavior(
      DocumentId documentId,
      List<HTextFlow> hTextFlows,
      HLocale hLocale,
      int startIndex,
      int count) {
    // @formatter:off
    GetTransUnitListHandler handler =
        SeamAutowire.instance()
            .use("identity", identity)
            .use("textFlowDAO", textFlowDAO)
            .use("textFlowSearchServiceImpl", textFlowSearchServiceImpl)
            .use("localeServiceImpl", localeServiceImpl)
            .use("resourceUtils", resourceUtils)
            .autowire(GetTransUnitListHandler.class);
    // @formatter:on

    int maxSize = Math.min(startIndex + count, hTextFlows.size());
    when(textFlowDAO.getTextFlows(documentId, startIndex, count))
        .thenReturn(hTextFlows.subList(startIndex, maxSize));
    when(localeServiceImpl.validateLocaleByProjectIteration(
            any(LocaleId.class), anyString(), anyString()))
        .thenReturn(hLocale);
    when(resourceUtils.getNumPlurals(any(HDocument.class), any(HLocale.class))).thenReturn(1);

    // trans unit navigation index handler
    when(textFlowDAO.getNavigationByDocumentId(
            eq(documentId.getId()),
            eq(hLocale),
            isA(ResultTransformer.class),
            isA(FilterConstraints.class)))
        .thenReturn(hTextFlows);
    return handler;
  }