@Test public void testGenerateCreateActivity() { Upload upload = this.getASampleUpload(false, 4); UploadActivityGenerator uploadActivityGeneratorSpa = Mockito.spy(uploadActivityGenerator); Activity activity = uploadActivityGeneratorSpa.generateCreateActivity(upload); assertEquals(CREATE, activity.getAction()); assertEquals(CREATE_SUBJECT, activity.getSubject()); runCommonEquals(upload, activity); }
@Test public void testGenerateDiscardActivity() { Upload originUpload = this.getASampleUpload(false, 4); Upload modifiedUpload = this.getASampleUpload(true, 4); UploadActivityGenerator uploadActivityGeneratorSpa = Mockito.spy(uploadActivityGenerator); Activity activity = uploadActivityGeneratorSpa.generateUpdateActivity(originUpload, modifiedUpload); assertEquals(DISCARD, activity.getAction()); assertEquals(DISCARD_SUBJECT, activity.getSubject()); runCommonEquals(originUpload, activity); }
@Test public void testGenerateMoveActivityDeleteIsNullAndNotEquals() { Upload originUpload = this.getASampleUpload(null, 4); Upload modifiedUpload = this.getASampleUpload(null, 5); UploadActivityGenerator uploadActivityGeneratorSpa = Mockito.spy(uploadActivityGenerator); Activity activity = uploadActivityGeneratorSpa.generateUpdateActivity(originUpload, modifiedUpload); assertEquals(MOVE, activity.getAction()); assertEquals(MOVE_SUBJECT, activity.getSubject()); runCommonEquals(modifiedUpload, activity); }
@Test public void testEnrichModel() { Upload identifiable = getASampleUpload(false, 4); UploadActivityGenerator uploadActivityGeneratorSpy = Mockito.spy(uploadActivityGenerator); Mockito.doReturn(identifiable).when(uploadService).getById(id); BaseProjectItem upload = uploadActivityGeneratorSpy.enrichModel(identifiable); Mockito.verify(uploadService, Mockito.times(1)).getById(id); Mockito.verifyNoMoreInteractions(uploadService); assertEquals(upload.getId(), Integer.valueOf(id)); }