Tabnine Logo
JobInfo.newJobInfo
Code IndexAdd Tabnine to your IDE (free)

How to use
newJobInfo
method
in
de.otto.edison.jobs.domain.JobInfo

Best Java code snippets using de.otto.edison.jobs.domain.JobInfo.newJobInfo (Showing top 20 results out of 315)

origin: otto-de/edison-microservice

private JobInfo createJobInfo(final String jobType) {
  return newJobInfo(uuidProvider.getUuid(), jobType, clock,
      systemInfo.getHostname());
}
origin: otto-de/edison-microservice

private JobInfo.Builder defaultJobInfo() {
  return newJobInfo(JOB_ID, JOB_TYPE, clock, HOSTNAME).copy();
}
origin: otto-de/edison-microservice

  private JobInfo defaultJobInfo(String jobId, int secondsAgo) {
    OffsetDateTime lastUpdated = OffsetDateTime.ofInstant(now(clock).minus(secondsAgo, SECONDS), systemDefault());
    return newJobInfo(jobId, "someJobType", OffsetDateTime.MIN, lastUpdated, Optional.empty(), OK, emptyList(), clock, "someHostname");
  }
}
origin: otto-de/edison-microservice

  private JobInfo someRunningJobInfo(final String jobId, final String type, final OffsetDateTime started) {
    return JobInfo.newJobInfo(
        jobId,
        type,
        started, started.plus(1, SECONDS), Optional.empty(), OK,
        Collections.emptyList(),
        systemDefaultZone(),
        "localhost"
    );
  }
}
origin: otto-de/edison-microservice

@Test
public void shouldReturnAllJobs() throws IOException {
  // given
  JobInfo firstJob = newJobInfo("42", "TEST", fixed(ofEpochMilli(0), systemDefault()), "localhost");
  JobInfo secondJob = newJobInfo("42", "TEST", fixed(ofEpochMilli(1), systemDefault()), "localhost");
  when(jobService.findJobs(Optional.<String>empty(), 100)).thenReturn(asList(firstJob, secondJob));
  // when
  Object job = jobsController.getJobsAsJson(null, 100, false, false, mock(HttpServletRequest.class));
  // then
  assertThat(job, is(asList(representationOf(firstJob, null, false, "", ""), representationOf(secondJob, null, false, "", ""))));
}
origin: otto-de/edison-microservice

  private JobInfo jobInfoWithRuntime(int finishAmount, ChronoUnit unit) {
    final Clock clock = fixed(Instant.now(), systemDefault());
    final OffsetDateTime startTime = now(clock);
    final OffsetDateTime finishedTime = startTime.plus(finishAmount, unit);
    return newJobInfo("foo", "TEST", startTime, finishedTime, of(finishedTime), OK, emptyList(), clock, "localhost");
  }
}
origin: otto-de/edison-microservice

@Test
@SuppressWarnings("unchecked")
public void shouldReturnAllJobsOfTypeAsHtml() {
  JobInfo firstJob = newJobInfo("42", "SOME_TYPE", systemDefaultZone(), "localhost");
  when(jobService.findJobs(Optional.of("SOME_TYPE"), 100)).thenReturn(asList(firstJob));
  ModelAndView modelAndView = jobsController.getJobsAsHtml("SOME_TYPE", 100, false, mock(HttpServletRequest.class));
  List<JobRepresentation> jobs = (List<JobRepresentation>) modelAndView.getModel().get("jobs");
  assertThat(jobs, is(asList(representationOf(firstJob, null, false, "", ""))));
}
origin: otto-de/edison-microservice

@Test
public void shouldFindAll() {
  // given
  repository.createOrUpdate(newJobInfo("oldest", "FOO", fixed(Instant.now().minusSeconds(1), systemDefault()), "localhost"));
  repository.createOrUpdate(newJobInfo("youngest", "FOO", fixed(Instant.now(), systemDefault()), "localhost"));
  // when
  final List<JobInfo> jobInfos = repository.findAll();
  // then
  assertThat(jobInfos.size(), is(2));
  assertThat(jobInfos.get(0).getJobId(), is("youngest"));
  assertThat(jobInfos.get(1).getJobId(), is("oldest"));
}
origin: otto-de/edison-microservice

@Test
public void shouldFindRunningJobsWithoutUpdatedSinceSpecificDate() throws Exception {
  // given
  repository.createOrUpdate(newJobInfo("deadJob", "FOO", fixed(Instant.now().minusSeconds(10), systemDefault()), "localhost"));
  repository.createOrUpdate(newJobInfo("running", "FOO", fixed(Instant.now(), systemDefault()), "localhost"));
  // when
  final List<JobInfo> jobInfos = repository.findRunningWithoutUpdateSince(now().minus(5, ChronoUnit.SECONDS));
  // then
  assertThat(jobInfos, IsCollectionWithSize.hasSize(1));
  assertThat(jobInfos.get(0).getJobId(), is("deadJob"));
}
origin: otto-de/edison-microservice

@Test
public void shouldFindStatusOfJob() throws Exception {
  //Given
  final String type = "TEST";
  JobInfo jobInfo = newJobInfo("1", type, systemDefaultZone(), "localhost");
  repository.createOrUpdate(jobInfo);
  //When
  JobStatus status = repository.findStatus("1");
  //Then
  assertThat(status, is(JobStatus.OK));
}
origin: otto-de/edison-microservice

@Test
public void shouldRunJob() {
  // given:
  String jobType = "bar";
  when(jobRunnable.getJobDefinition()).thenReturn(someJobDefinition(jobType));
  // when:
  Optional<String> optionalJobId = jobService.startAsyncJob(jobType);
  // then:
  final JobInfo expectedJobInfo = JobInfo.newJobInfo(optionalJobId.get(), jobType, clock, systemInfo.hostname);
  verify(executorService).execute(any(Runnable.class));
  verify(jobRepository).createOrUpdate(expectedJobInfo);
  verify(jobRunnable).execute();
  verify(jobMetaService).aquireRunLock(expectedJobInfo.getJobId(), expectedJobInfo.getJobType());
}
origin: otto-de/edison-microservice

@Test
public void shouldFindJobInfoByUri() {
  // given
  InMemJobRepository repository = new InMemJobRepository();
  // when
  JobInfo job = newJobInfo(randomUUID().toString(), "MYJOB", clock, "localhost");
  repository.createOrUpdate(job);
  // then
  assertThat(repository.findOne(job.getJobId()), isPresent());
}
origin: otto-de/edison-microservice

@Test
public void shouldNotRemoveRunningJobs() {
  // given
  final String testUri = "test";
  repository.createOrUpdate(newJobInfo(testUri, "FOO", systemDefaultZone(), "localhost"));
  // when
  repository.removeIfStopped(testUri);
  // then
  assertThat(repository.size(), is(1L));
}
origin: otto-de/edison-microservice

@Test
public void shouldKillJob() {
  OffsetDateTime now = OffsetDateTime.now(clock);
  JobInfo jobInfo = JobInfo.newJobInfo("superId", "superType", clock, HOSTNAME);
  when(jobRepository.findOne("superId")).thenReturn(Optional.of(jobInfo));
  jobService.killJob("superId");
  JobInfo expected = jobInfo.copy().setStatus(JobInfo.JobStatus.DEAD).setStopped(now).setLastUpdated(now).build();
  verify(jobMetaService).releaseRunLock("superType");
  verify(jobRepository).createOrUpdate(expected);
}
origin: otto-de/edison-microservice

@Test
public void shouldStopJob() {
  OffsetDateTime now = OffsetDateTime.now(clock);
  Clock earlierClock = offset(clock, Duration.of(-1, MINUTES));
  JobInfo jobInfo = JobInfo.newJobInfo("superId", "superType", earlierClock, HOSTNAME);
  when(jobRepository.findOne("superId")).thenReturn(Optional.of(jobInfo));
  jobService.stopJob("superId");
  JobInfo expected = jobInfo.copy().setStatus(JobInfo.JobStatus.OK).setStopped(now).setLastUpdated(now).build();
  verify(jobMetaService).releaseRunLock("superType");
  verify(jobRepository).createOrUpdate(expected);
}
origin: otto-de/edison-microservice

private JobInfo someJobInfo(final String jobId) {
  return JobInfo.newJobInfo(
      jobId,
      "SOME_JOB",
      now(), now(), Optional.of(now()), OK,
      asList(
          jobMessage(Level.INFO, "foo", now()),
          jobMessage(Level.WARNING, "bar", now())),
      systemDefaultZone(),
      "localhost"
  );
}
origin: otto-de/edison-microservice

private JobInfo jobInfo(final String jobId, final String type) {
  return JobInfo.newJobInfo(
      jobId,
      type,
      now(), now(), Optional.of(now()), OK,
      asList(
          jobMessage(Level.INFO, "foo", now()),
          jobMessage(Level.WARNING, "bar", now())),
      systemDefaultZone(),
      "localhost"
  );
}
origin: otto-de/edison-microservice

  private JobInfo jobInfo(final String jobId, final String type) {
    return JobInfo.newJobInfo(
        jobId,
        type,
        now(), now(), Optional.of(now()), OK,
        asList(
            jobMessage(Level.INFO, "foo", now()),
            jobMessage(Level.WARNING, "bar", now())),
        systemDefaultZone(),
        "localhost"
    );
  }
}
origin: de.otto.edison/edison-mongo

@Override
protected final JobInfo decode(final Document document) {
  return newJobInfo(
      document.getString(JobStructure.ID.key()),
      document.getString(JobStructure.JOB_TYPE.key()),
      DateTimeConverters.toOffsetDateTime(document.getDate(JobStructure.STARTED.key())),
      DateTimeConverters.toOffsetDateTime(document.getDate(JobStructure.LAST_UPDATED.key())),
      ofNullable(DateTimeConverters.toOffsetDateTime(document.getDate(JobStructure.STOPPED.key()))),
      JobStatus.valueOf(document.getString(JobStructure.STATUS.key())),
      getMessagesFrom(document),
      clock,
      document.getString(JobStructure.HOSTNAME.key()));
}
origin: otto-de/edison-microservice

@Override
protected final JobInfo decode(final Document document) {
  return newJobInfo(
      document.getString(JobStructure.ID.key()),
      document.getString(JobStructure.JOB_TYPE.key()),
      toOffsetDateTime(document.getDate(JobStructure.STARTED.key())),
      toOffsetDateTime(document.getDate(JobStructure.LAST_UPDATED.key())),
      ofNullable(toOffsetDateTime(document.getDate(JobStructure.STOPPED.key()))),
      JobStatus.valueOf(document.getString(JobStructure.STATUS.key())),
      getMessagesFrom(document),
      clock,
      document.getString(JobStructure.HOSTNAME.key()));
}
de.otto.edison.jobs.domainJobInfonewJobInfo

Popular methods of JobInfo

  • getJobId
  • getJobType
  • getLastUpdated
  • getMessages
  • getStarted
  • getStatus
  • getStopped
  • isStopped
  • copy
  • getHostname
  • <init>
  • builder
  • <init>,
  • builder,
  • equals,
  • getClock,
  • hashCode

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
  • notifyDataSetChanged (ArrayAdapter)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • JComboBox (javax.swing)
  • JTextField (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now