driftServer.driftDef = driftDef;
int resourceId = 1;
// First create the change set from which the pinned change set will be created
DriftChangeSetDTO changeSetDTO = new DriftChangeSetDTO();
changeSetDTO.setResourceId(resourceId);
changeSetDTO.setDriftDefinitionId(driftDef.getId());
changeSetDTO.setDriftHandlingMode(plannedChanges);
changeSetDTO.setCategory(COVERAGE);
changeSetDTO.setCtime(new Date().getTime());
changeSetDTO.setVersion(0);
Set<DriftDTO> driftDTOs = new HashSet<DriftDTO>();
DriftDTO drift1DTO = new DriftDTO();
drift1DTO.setChangeSet(changeSetDTO);
drift1DTO.setCategory(FILE_ADDED);
drift1DTO.setPath("./1.bin");
drift1DTO.setDirectory(".");
drift1DTO.setCtime(new Date().getTime());
drift1DTO.setNewDriftFile(newDriftFile(sha256("./1.bin")));
driftDTOs.add(drift1DTO);
DriftDTO drift2DTO = new DriftDTO();
drift2DTO.setChangeSet(changeSetDTO);
drift2DTO.setCategory(FILE_ADDED);
drift2DTO.setPath("./2.bin");
drift2DTO.setDirectory(".");
drift2DTO.setCtime(new Date().getTime());
drift2DTO.setNewDriftFile(newDriftFile(sha256("./2.bin")));
driftDTOs.add(drift2DTO);
changeSetDTO.setDrifts(driftDTOs);
driftServer.persistChangeSet(null, changeSetDTO);
GenericDriftChangeSetCriteria criteria = new GenericDriftChangeSetCriteria();
criteria.addFilterDriftDefinitionId(driftDef.getId());
criteria.fetchDrifts(true);
List<MongoDBChangeSet> changeSets = changeSetDAO.findByChangeSetCritiera(criteria);
assertEquals(changeSets.size(), 1, "There should only be one change set for drift definition id " +
driftDef.getId());
Mapper mapper = new Mapper();
DriftChangeSetDTO actualChangeSet = mapper.toDTO(changeSets.get(0));
Set<DriftDTO> actualDrifts = new HashSet<DriftDTO>();
for (MongoDBChangeSetEntry entry : changeSets.get(0).getDrifts()) {
actualDrifts.add(mapper.toDTO(entry));
}