Package net.caprazzi.minima.model

Examples of net.caprazzi.minima.model.Note


  @Test
  public void upgradeFrom0to1_should_upgrade_each_story() throws Exception {
    minimaDb = spy(new DbHelper(db));
   
    Entry[] entries = new Entry[] {
      new Entry("story1", 1, new Note("desc1","todo", 65536, false).toJson()),
      new Entry("story2", 2, new Note("desc2","todo", 65536, false).toJson())
    };
   
    doAnswer(listFound(entries)).when(db).list(any(List.class));
   
    minimaDb.upgradeFrom0to1();
View Full Code Here


  @Test
  public void upgradeFrom0to1_should_delete_old_stories_after_upgrade() throws Exception {
    minimaDb = spy(new DbHelper(db));
   
    Entry[] entries = new Entry[] {
      new Entry("story1", 1, new Note("desc1","todo", 65536, false).toJson()),
      new Entry("story2", 2, new Note("desc1","todo", 65536, false).toJson()),
    };
   
    doAnswer(listFound(entries)).when(db).list(any(List.class));
   
    minimaDb.upgradeFrom0to1();
View Full Code Here

  @Test
  public void upgradeFrom0To1_should_rollback_if_any_upgrade_fails_then_throw() throws Exception {
    minimaDb = spy(new DbHelper(db));
   
    Entry[] entries = new Entry[] {
      new Entry("story1", 1, new Note("desc1","todo", 65536, false).toJson()),
      new Entry("story2", 2, new Note("desc1","todo", 65536, false).toJson()),
      new Entry("story3", 2, new Note("desc1","todo", 65536, false).toJson()),
    };
   
    doAnswer(listFound(entries)).when(db).list(any(List.class));
   
    doThrow(new Exception()).when(minimaDb).upgradeEntry(entries[1]);
View Full Code Here

  @Test
  public void upgradeFrom0To1_rollback_keeps_going_if_rollback_fails_then_throw() throws Exception {
    minimaDb = spy(new DbHelper(db));
   
    Entry[] entries = new Entry[] {
      new Entry("story0", 0, new Note("desc1","todo", 65536, false).toJson()),
      new Entry("story1", 1, new Note("desc1","todo", 65536, false).toJson()),
      new Entry("story2", 2, new Note("desc1","todo", 65536, false).toJson())
    };
   
    doAnswer(listFound(entries)).when(db).list(any(List.class));
    doThrow(new Exception()).when(minimaDb).upgradeEntry(entries[1]);
    doThrow(new Exception()).when(minimaDb).rollbackUpgradeEntry(entries[0]);
View Full Code Here

            List list = (List)doc;
            if (!list.isArchived())
              lists.put(list.getId(), list);
          }
          else if (doc.getTypeName().equals("story")) {
            Note note = (Note)doc;
            if (!note.isArchived())
            notes.add(note);
          }
        }
       
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode root = mapper.createObjectNode();
       
        ArrayNode listsNode = mapper.createArrayNode();
        root.put("lists", listsNode);
        for (List list : lists.values()) {
          listsNode.add(list.toJsonNode());
        }
       
        ArrayNode notesNode = mapper.createArrayNode();
        root.put("stories", notesNode);
        for (Note note : notes) {
          if (lists.containsKey(note.getList()))
          notesNode.add(note.toJsonNode());
        }               
     
        try {         
          resp.setContentType("application/json");
          ServletOutputStream out = resp.getOutputStream();
View Full Code Here

TOP

Related Classes of net.caprazzi.minima.model.Note

Copyright © 2018 www.massapicom. 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.