@Test public void should_set_id() throws Exception { final String id = "493410b3-dd0b-4b78-97bf-289f50f6e74f"; UUID uuid = UUID.fromString(id); mockStatic(UUID.class); when(UUID.randomUUID()).thenReturn(uuid); DocumentService documentService = new DocumentService(); JsonDocument document = new JsonDocument(); documentService.saveDocument(document); assertThat(document.getId()) .as("Id is set") .isEqualTo(id); }
public JsonDocument saveDocument(JsonDocument document){ UUID uuid = UUID.randomUUID(); document.setId(uuid.toString()); return document; }
DocumentService { public JsonDocument saveDocument(JsonDocument document){ UUID uuid = UUID.randomUUID(); document.setId(uuid.toString()); return document; } }
DocumentService { public JsonDocument saveDocument(JsonDocument document){ UUID uuid = UUID.randomUUID(); document.setId(uuid.toString()); return document; }  }
DocumentService { public JsonDocument saveDocument(JsonDocument document){ UUID uuid = UUID.randomUUID(); document.setId(uuid.toString()); return document; }  JsonDocument saveDocument(JsonDocument document); }
DocumentService { public JsonDocument saveDocument(JsonDocument document){ UUID uuid = UUID.randomUUID(); document.setId(uuid.toString()); return document; }  JsonDocument saveDocument(JsonDocument document);  }