コード例 #1
0
  @Test
  public void shouldFetchColumnsForRnr() throws Exception {
    long programId = 1L;
    rnrTemplateController.fetchColumnsForRequisition(programId);

    verify(rnrTemplateService).fetchColumnsForRequisition(1L);
  }
コード例 #2
0
  @Test
  public void shouldGetMasterColumnListForRnR() {
    List<RnrColumn> allColumns = new ArrayList<>();

    when(rnrTemplateService.fetchAllRnRColumns(existingProgramId)).thenReturn(allColumns);
    RnrTemplateForm rnrColumns =
        rnrTemplateController.fetchAllProgramRnrColumnList(existingProgramId);
    verify(rnrTemplateService).fetchAllRnRColumns(existingProgramId);
    assertThat(rnrColumns.getRnrColumns(), is(allColumns));
  }
コード例 #3
0
  @Test
  public void shouldCreateARnRTemplateForAGivenProgramWithSpecifiedColumns() throws Exception {
    final RnrColumnList rnrColumns = new RnrColumnList();

    MockHttpServletRequest request = new MockHttpServletRequest();

    when(rnrTemplateService.saveRnRTemplateForProgram((ProgramRnrTemplate) any()))
        .thenReturn(new HashMap<String, OpenLmisMessage>());
    when(messageService.message("template.save.success")).thenReturn("dummy success");
    ResponseEntity<OpenLmisResponse> responseEntity =
        rnrTemplateController.saveRnRTemplateForProgram(existingProgramId, rnrColumns, request);

    assertThat(responseEntity.getBody().getSuccessMsg(), is("dummy success"));
  }
コード例 #4
0
  @Test
  public void shouldReturnErrorMessagesForCorrespondingFields() throws Exception {

    RnrColumnList rnrColumns = new RnrColumnList();
    MockHttpServletRequest request = new MockHttpServletRequest();
    HashMap<String, OpenLmisMessage> errorMap = new HashMap<>();
    OpenLmisMessage openLmisMessage = new OpenLmisMessage("code", "param1", "param2");
    errorMap.put("key", openLmisMessage);
    when(rnrTemplateService.saveRnRTemplateForProgram((ProgramRnrTemplate) any()))
        .thenReturn(errorMap);
    when(messageService.message(openLmisMessage.getCode(), openLmisMessage.getParams()))
        .thenReturn("dummy message param1 param2");

    ResponseEntity<OpenLmisResponse> responseEntity =
        rnrTemplateController.saveRnRTemplateForProgram(existingProgramId, rnrColumns, request);

    assertThat(
        (String) responseEntity.getBody().getData().get("key"), is("dummy message param1 param2"));
  }