### Question:
DeltaExtractor implements InitializingBean { public void execute(String tenant, File tenantDirectory, DateTime deltaUptoTime) { TenantContext.setTenantId(tenant); audit(securityEventUtil.createSecurityEvent(this.getClass().getName(), "Delta Extract Initiation", LogLevelType.TYPE_INFO, BEMessageCode.BE_SE_CODE_0019, DATE_TIME_FORMATTER.print(deltaUptoTime))); Map<String, Set<String>> appsPerEdOrg = appsPerEdOrg(); ExtractFile publicDeltaExtractFile = createPublicExtractFile(tenantDirectory, deltaUptoTime); deltaEntityIterator.init(tenant, deltaUptoTime); while (deltaEntityIterator.hasNext()) { DeltaRecord delta = deltaEntityIterator.next(); if (delta.getOp() == Operation.UPDATE) { extractUpdate(delta, publicDeltaExtractFile, appsPerEdOrg, tenantDirectory, deltaUptoTime); } else if (delta.getOp() == Operation.DELETE) { extractDelete(delta, publicDeltaExtractFile, appsPerEdOrg, tenantDirectory, deltaUptoTime); } else if (delta.getOp() == Operation.PURGE) { extractPurge(delta, publicDeltaExtractFile, appsPerEdOrg, tenantDirectory, deltaUptoTime); } } logEntityCounts(); audit(securityEventUtil.createSecurityEvent(this.getClass().getName(), "Delta Extract Finished", LogLevelType.TYPE_INFO, BEMessageCode.BE_SE_CODE_0021, DATE_TIME_FORMATTER.print(deltaUptoTime))); finalizeExtraction(tenant, deltaUptoTime); }  @Override void afterPropertiesSet(); void execute(String tenant, File tenantDirectory, DateTime deltaUptoTime); void setSecurityEventUtil(SecurityEventUtil securityEventUtil); static final DateTimeFormatter DATE_TIME_FORMATTER; static final String DATE_FIELD; static final String TIME_FIELD; }### Answer:
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testPublicAndPrivate() { when(deltaEntityIterator.hasNext()).thenReturn(true, true, true, false); when(deltaEntityIterator.next()).thenReturn(buildUpdatePublicRecord(), buildDeleteRecord(), buildUpdatePrivateRecord()); extractor.execute("Midgar", null, new DateTime()); verify(entityExtractor, times(2)).write(any(Entity.class), any(ExtractFile.class), any(EntityExtractor.CollectionWrittenRecord.class), (Predicate) Mockito.isNull()); verify(entityWriteManager, times(14)).writeDeleteFile(any(Entity.class), any(ExtractFile.class)); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testPrivateOnly() { when(deltaEntityIterator.hasNext()).thenReturn(true, true, false); when(deltaEntityIterator.next()).thenReturn(buildUpdatePrivateRecord(), buildDeleteRecord()); extractor.execute("Midgar", null, new DateTime()); verify(entityExtractor, times(1)).write(any(Entity.class), any(ExtractFile.class), any(EntityExtractor.CollectionWrittenRecord.class), (Predicate) Mockito.isNull()); verify(entityWriteManager, times(8)).writeDeleteFile(any(Entity.class), any(ExtractFile.class)); }
@Test public void testPurge() { when(deltaEntityIterator.hasNext()).thenReturn(true, false); when(deltaEntityIterator.next()).thenReturn(buildPurgeRecord()); extractor.execute("Midgar", null, new DateTime()); verify(entityWriteManager, times(3)).writeDeleteFile(any(Entity.class), any(ExtractFile.class)); }