Пример #1
0
  /** Test that the left column gets refreshed properly. */
  @Test
  public void testRefreshLeftColumn() {
    context.turnOffAuthorization();

    Person person = personRepo.findPersonByEmail("*****@*****.**");
    Submission submission = subRepo.createSubmission(person);
    submission.setDocumentTitle("My Document Title");
    State state = stateManager.getState("InReview");
    submission.setState(state);
    EmbargoType embargo = settingRepo.findAllEmbargoTypes().get(0);
    submission.addEmbargoType(embargo);
    submission.save();
    Long id = submission.getId();

    assertEquals("My Document Title", submission.getDocumentTitle());

    JPA.em().getTransaction().commit();
    JPA.em().clear();
    JPA.em().getTransaction().begin();

    LOGIN();

    String UPDATE_URL = Router.reverse("ViewTab.updateJSON").url;

    Map<String, String> params = new HashMap<String, String>();
    params.put("subId", id.toString());
    params.put("field", "title");
    params.put("value", "This is a new title");

    Response response = POST(UPDATE_URL, params);
    assertIsOk(response);
    assertContentMatch("\"success\": true,", response);

    submission = subRepo.findSubmission(id);

    UPDATE_URL = Router.reverse("ViewTab.refreshLeftColumn").url;

    params.clear();
    params.put("id", id.toString());

    response = POST(UPDATE_URL, params);
    assertIsOk(response);
    assertContentMatch("Document title changed to", response);

    submission.delete();

    context.restoreAuthorization();
  }