ScheduledTaskEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, ScheduledTask> scheduledTaskMap = Optional.ofNullable(bundle.getScheduledTasks()).orElse(Collections.emptyMap()); return buildEntities(scheduledTaskMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getScheduledTasks(), bundle, bundleType, document); } } @Inject  ScheduledTaskEntityBuilder(IdGenerator idGenerator); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }
@Test void buildFromEmptyBundle_noScheduledTask() { ScheduledTaskEntityBuilder builder = new ScheduledTaskEntityBuilder(ID_GENERATOR); final List<Entity> entities = builder.build(new Bundle(), BundleType.DEPLOYMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertTrue(entities.isEmpty()); }
@Test void buildEnvironment() { final Bundle bundle = new Bundle(); ScheduledTaskEntityBuilder builder = new ScheduledTaskEntityBuilder(ID_GENERATOR); ScheduledTask scheduledTask = buildTestScheduledTask(false); bundle.putAllScheduledTasks(ImmutableMap.of(TEST_SCHEDULED_TASK, scheduledTask)); final List<Entity> entities = builder.build(bundle, ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument()); assertTrue(entities.isEmpty()); }