Examples of BusinessObjectService


Examples of org.kuali.rice.krad.service.BusinessObjectService

  public void testProcess() throws Exception {
    SplitResult result = annexTypeApprovalSplit.process(null, null);
    assertNotNull("split result should not be null", result);
    assertTrue("branch list should be empty", result.getBranchNames().isEmpty());
   
    BusinessObjectService boSvc = mock(BusinessObjectService.class);
    annexTypeApprovalSplit.setBusinessObjectService(boSvc);
   
    RouteContext context = mock(RouteContext.class);
    DocumentRouteHeaderValue docHdr = mock(DocumentRouteHeaderValue.class);
    when(context.getDocument()).thenReturn(docHdr);
   
    MatterWork work = mock(MatterWork.class);
    MatterAnnexType annexType = new MatterAnnexType();
    when(work.getAnnexType()).thenReturn(annexType);
   
    final String documentId = "2013";
    when(docHdr.getDocumentId()).thenReturn(documentId);
    when(boSvc.findBySinglePrimaryKey(same(MatterWork.class), same(documentId))).thenReturn(work);
    assertTrue("branch list should be empty since requiresApproval is by default false"
        annexTypeApprovalSplit.process(context, null).getBranchNames().isEmpty());
   
    annexType.setRequiresApproval(true);
    final List<String> branchNames = annexTypeApprovalSplit.process(context, null).getBranchNames();
    assertFalse("branch list should not be empty since requiresApproval is set to true", branchNames.isEmpty());
    assertEquals("branch name differs", MartinlawConstants.RoutingBranches.ANNEX_TYPE_APPROVAL, branchNames.get(0));
   
    when(work.getAnnexType()).thenReturn(null);
    assertTrue("branch list should be empty since annex type is null"
        annexTypeApprovalSplit.process(context, null).getBranchNames().isEmpty());
   
    when(docHdr.getDocumentId()).thenReturn("none existent doc id");
    assertFalse("branch list should not be empty if document does not exist, workflow testing mode is assumed"
        annexTypeApprovalSplit.process(context, null).getBranchNames().isEmpty());
   
    when(boSvc.findBySinglePrimaryKey(same(MatterWork.class), same(documentId))).thenReturn(null);
    assertFalse("branch list should not be empty since when work is null, workflow testing mode is assumed"
        annexTypeApprovalSplit.process(context, null).getBranchNames().isEmpty());
  }
View Full Code Here

Examples of org.kuali.rice.krad.service.BusinessObjectService

   */
  @Test
  public void testDownloadCaseAttachment() throws IOException {
    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getParameter("attachmentId")).thenReturn("1001");
    BusinessObjectService boSvc = mock(BusinessObjectService.class);
    controller.setBusinessObjectService(boSvc);
    when(boSvc.findBySinglePrimaryKey(Attachment.class, 1001l)).thenReturn(att);
    controller.downloadAttachmentById(null, null, request, response);
    testDownloadAttachmentAsStream();
  }
View Full Code Here

Examples of org.kuali.rice.krad.service.BusinessObjectService

   * Test method for {@link org.martinlaw.keyvalues.ScopedKeyValuesHelper#getKeyValues(java.lang.String, java.lang.Class)}.
   */
  @Test
  public void testGetKeyValues() {
    ScopedKeyValuesHelper keyValuesHelper = new ScopedKeyValuesHelper();
    BusinessObjectService boSvc = mock(BusinessObjectService.class);
    keyValuesHelper.setBusinessObjectService(boSvc);
   
    String marriageClassName = "org.Marriage";
    String weddingClassName = "org.Wedding";
    String foodClassName = "org.Food";
    Class<? extends BusinessObject> scopedClass = Status.class;
   
    List<Status> statusList = new ArrayList<Status>(3);
   
    final String statusChristian = "Christian";
    Status status1 = new Status(1l, statusChristian);
    Scope[] scope1 = {new Scope(marriageClassName), new Scope(weddingClassName)};
    status1.setScope(Arrays.asList(scope1));
   
    final String statusFulfld = "Fulfilled";
    Status status2 = new Status(1l, statusFulfld);
    Scope[] scope2 = {new Scope(marriageClassName)};
    status2.setScope(Arrays.asList(scope2));
   
    // status 'good applies to all classes, so leave scope blank
    final String statusGd = "Good";
    Status status3 = new Status(1l, statusGd);
    statusList.add(status1);
    statusList.add(status2);
    statusList.add(status3);
    when(boSvc.findAll(same(Status.class))).thenReturn(statusList);
   
    List<KeyValue> keyValuesResult = keyValuesHelper.getKeyValues(marriageClassName, scopedClass);
    String [] expectedStatusArray = {statusChristian, statusFulfld, statusGd};
    testKeyValuesResult(expectedStatusArray, keyValuesResult);
   
View Full Code Here

Examples of org.kuali.rice.krad.service.BusinessObjectService

   * Test method for {@link org.martinlaw.auth.OpenidUserDetailsService#loadUserByUsername(java.lang.String)}.
   */
  @Test
  public void testLoadUserByUsername_existing_principal_no_openid() {
   
    BusinessObjectService boSvc = mock(BusinessObjectService.class);
    // simulate not finding any openid url in the db
    when(boSvc.findMatching(same(EntityExternalIdentifierBo.class), anyMapOf(String.class, String.class))).thenReturn(
        Collections.<EntityExternalIdentifierBo> emptyList());
   
    OpenidUserDetailsService usrDetSvc = new OpenidUserDetailsService();
    usrDetSvc.setBusinessObjectService(boSvc);
    final String openidUrl = "http://localhost/karani-openid.html";
View Full Code Here

Examples of org.kuali.rice.krad.service.BusinessObjectService

   
    OpenIDAuthenticationToken token = new OpenIDAuthenticationToken(null, "url", "msg", attributes);
    context.setAuthentication(token);
    SecurityContextHolder.setContext(context);
   
    BusinessObjectService boSvc = mock(BusinessObjectService.class);
    successHandler.setBusinessObjectService(boSvc);
    assertEquals("no email attribute has been set in the token", noEmailOrTokenError, successHandler.getActivationMessage());
   
    // add email attribute
    OpenIDAttribute emailAttr = new OpenIDAttribute("email", "email_type", values);
    attributes.add(emailAttr);
    // simulate not finding an entity with the email provided
    when(boSvc.findMatching(same(EntityEmailBo.class), anyMapOf(String.class, String.class))).thenReturn(
        Collections.<EntityEmailBo> emptyList());
    // mock entity info svc to return the mocked entity
    EntityInfoService entityInfoSvc = mock(org.martinlaw.auth.OpenIDSuccessAuthenticationSuccessHandler.EntityInfoService.class);
    when(entityInfoSvc.getEntityByEmail(emailFromOpenId)).thenReturn(null);
    successHandler.setEntityInfoService(entityInfoSvc);
    String expected = "Email address '" + emailFromOpenId + "' is not associated with an existing user :(";
    assertEquals("entity should not be found", expected, successHandler.getActivationMessage());
   
    // provide a mock entity object
    EntityBo entity = new EntityBo();
    EntityNameBo defaultName = new EntityNameBo();
    defaultName.setActive(true);
    defaultName.setDefaultValue(true);
    final String firstName = "Karani";
    defaultName.setFirstName(firstName);
    entity.getNames().add(defaultName);
    when(entityInfoSvc.getEntityByEmail(emailFromOpenId)).thenReturn(entity);
    // prepare the entity email to be found and so that the mock entity can be returned
    EntityEmailBo emailBo = new EntityEmailBo();
    final String entityId = "entity1";
    emailBo.setEntityId(entityId);
    List<EntityEmailBo> result = new ArrayList<EntityEmailBo>();
    result.add(emailBo);
    when(boSvc.findMatching(same(EntityEmailBo.class), anyMapOf(String.class, String.class))).thenReturn(result);
   
    // test that only active users with staff affiliation can log in
    // entity.setActive(true); - does not matter
    List<EntityAffiliationBo> affils = new ArrayList<EntityAffiliationBo>();
    entity.setAffiliations(affils);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.