NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

@Nested
@DisplayName("/all")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class GetAllIngestionJob {
private List<Long> ingestionJobIds;
private List<DcIngestionJob> ingestionJobs;
private Map<Long, IngestionJobSyncStatusDTO> ingestionJobSyncStatus;
private Map<Long, List<DcTag>> tags;

@BeforeEach
public void setup() {
ingestionJobIds = generateRandomListOfLong(30, 10);
ingestionJobs = ingestionJobIds.stream().map(id -> {
DcIngestionJob ingestionJob = new DcIngestionJob();
ingestionJob.setPkDcIngestionJobId(id);
DcConnection connection = new DcConnection();
DcDataSource dcDataSource = new DcDataSource();
MapDataSourceProvider mapDataSourceProvider = new MapDataSourceProvider();
DcCategory dcCategory = new DcCategory();
DcObject dcObject = new DcObject();
dcDataSource.setPkDcDataSourceId(id);
mapDataSourceProvider.setDcDataSource(dcDataSource);
connection.setMapDataSourceProvider(mapDataSourceProvider);
ingestionJob.setDcConnection(connection);
ingestionJob.setDcCategory(dcCategory);
dcObject.setId(id);
ingestionJob.setDcObject(dcObject);
return ingestionJob;
}).collect(Collectors.toList());

ingestionJobSyncStatus = ingestionJobIds.stream().collect(Collectors.toMap(id -> id, id -> {
IngestionJobSyncStatusDTO ingestionJobSyncStatusDTO = new IngestionJobSyncStatusDTO();
ingestionJobSyncStatusDTO.setLastSyncStatus(Constants.TEXT);
return ingestionJobSyncStatusDTO;
}));

tags = ingestionJobIds.stream().collect(Collectors.toMap(id -> id, id -> {
return generateRandomListOfLong(50, 41).stream().map(tagId -> {
DcTag tag = new DcTag();
tag.setPkDcTagId(tagId);
return tag;
}).collect(Collectors.toList());
}));
}

@Test
public void should_return_list_of_ingestionJobs_when_api_works() throws Exception {
when(ingestionJobManager.getIngestionJob(anyLong(), any(), any(), any(), any())).thenReturn(ingestionJobs);
when(ingestionJobManager.getDcIngestionJobSyncStatus(ingestionJobIds)).thenReturn(ingestionJobSyncStatus);
when(ingestionJobManager.getTotalCount(any(), anyLong())).thenReturn(Long.valueOf(ingestionJobIds.size()));
when(tagManager.getIngestionJobTags(anyListOf(Long.class))).thenReturn(tags);

CountDTO<IngestionJobListDTO> result = ingestionJobServiceImpl.getAllIngestionJob(10, 0);
Integer randomPosition = generateRandomInteger(result.getResults().size() - 1, 0);
IngestionJobDTO ingestionJobDTO = result.getResults().get(randomPosition).getIngestionJob();
List<TagDTO> jobTags = result.getResults().get(randomPosition).getTags();
List<Long> jobTagsIds = jobTags.stream().map(tag -> tag.getPkDcTagId()).collect(Collectors.toList());
Assertions.assertAll(() -> assertEquals(ingestionJobIds.size(), result.getCount()),
() -> assertTrue(ingestionJobIds.contains(ingestionJobDTO.getIngestionJobId())),
() -> assertTrue(tags.get(ingestionJobDTO.getIngestionJobId()).stream()
.map(tag -> tag.getPkDcTagId()).collect(Collectors.toList()).containsAll(jobTagsIds)));
}

@Test
public void should_return_null_when_ingestion_job_is_null() throws Exception {
when(ingestionJobManager.getIngestionJob(anyLong(), any(), any(), any(), any())).thenReturn(null);
when(ingestionJobManager.getDcIngestionJobSyncStatus(ingestionJobIds)).thenReturn(ingestionJobSyncStatus);
when(ingestionJobManager.getTotalCount(any(), anyLong())).thenReturn(Long.valueOf(ingestionJobIds.size()));
when(tagManager.getIngestionJobTags(anyListOf(Long.class))).thenReturn(tags);
Assertions.assertEquals(null, ingestionJobServiceImpl.getAllIngestionJob(10, 0));
}

@Test
public void should_return_size_when_ingestion_job_sync_status_is_empty() throws Exception {
when(ingestionJobManager.getIngestionJob(anyLong(), any(), any(), any(), any())).thenReturn(ingestionJobs);
when(ingestionJobManager.getDcIngestionJobSyncStatus(ingestionJobIds)).thenReturn(new HashMap<>());
when(ingestionJobManager.getTotalCount(any(), anyLong())).thenReturn(Long.valueOf(ingestionJobIds.size()));
when(tagManager.getIngestionJobTags(anyListOf(Long.class))).thenReturn(tags);

Assertions.assertTrue(ingestionJobServiceImpl.getAllIngestionJob(10, 0).getCount()
.equals(Long.valueOf(ingestionJobIds.size())));

}

@Test
public void should_return_size_when_tag_is_empty() throws Exception {
when(ingestionJobManager.getIngestionJob(anyLong(), any(), any(), any(), any())).thenReturn(ingestionJobs);
when(ingestionJobManager.getDcIngestionJobSyncStatus(ingestionJobIds)).thenReturn(ingestionJobSyncStatus);
when(ingestionJobManager.getTotalCount(any(), anyLong())).thenReturn(Long.valueOf(ingestionJobIds.size()));
when(tagManager.getIngestionJobTags(anyListOf(Long.class))).thenReturn(new HashMap<>());

Assertions.assertTrue(ingestionJobServiceImpl.getAllIngestionJob(10, 0).getCount()
.equals(Long.valueOf(ingestionJobIds.size())));

}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.