use of com.epam.ta.reportportal.database.entity.Launch in project commons-dao by reportportal.
the class LaunchRepositoryTest method findLatestLaunch.
@Test
public void findLatestLaunch() {
String project = "project";
String launch = "launch";
String mode = "DEFAULT";
Launch launch1 = new Launch();
launch1.setName(launch);
launch1.setProjectRef(project);
launch1.setMode(Mode.valueOf(mode));
launch1.setNumber(1L);
launch1.setStatus(Status.PASSED);
Launch launch2 = new Launch();
launch2.setName(launch);
launch2.setProjectRef(project);
launch2.setMode(Mode.valueOf(mode));
launch2.setNumber(2L);
launch2.setStatus(Status.IN_PROGRESS);
launchRepository.save(asList(launch1, launch2));
Optional<Launch> latestLaunch = launchRepository.findLatestLaunch(project, launch, mode);
Assert.assertTrue(latestLaunch.isPresent());
Assert.assertEquals(1L, latestLaunch.get().getNumber().longValue());
}
use of com.epam.ta.reportportal.database.entity.Launch in project commons-dao by reportportal.
the class LaunchRepositoryCustomImpl method findLastLaunch.
@Override
public Optional<Launch> findLastLaunch(String projectId, String launchName, String mode) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectId)).addCriteria(where(NAME).is(launchName)).addCriteria(where(MODE).is(mode)).limit(1).with(new Sort(Lists.newArrayList(new Sort.Order(DESC, START_TIME), new Sort.Order(DESC, NUMBER))));
List<Launch> launches = mongoTemplate.find(query, Launch.class);
return !launches.isEmpty() ? Optional.of(launches.get(0)) : Optional.empty();
}
use of com.epam.ta.reportportal.database.entity.Launch in project commons-dao by reportportal.
the class LaunchRepositoryCustomImpl method findLatestLaunch.
@Override
public Optional<Launch> findLatestLaunch(String projectName, String launchName, String mode) {
Query query = query(where(PROJECT_ID_REFERENCE).is(projectName)).addCriteria(where(NAME).is(launchName)).addCriteria(where(STATUS).ne(Status.IN_PROGRESS)).addCriteria(where(MODE).is(mode)).limit(1).with(new Sort(DESC, NUMBER));
List<Launch> launches = mongoTemplate.find(query, Launch.class);
return !launches.isEmpty() ? Optional.of(launches.get(0)) : Optional.empty();
}
use of com.epam.ta.reportportal.database.entity.Launch in project commons-dao by reportportal.
the class DeleteLaunchesListener method onBeforeDelete.
@Override
public void onBeforeDelete(BeforeDeleteEvent<Launch> event) {
DBObject dboq = queryMapper.getMappedObject(event.getDBObject(), mappingContext.getPersistentEntity(Launch.class));
List<String> ids = stream(mongoTemplate.getCollection(event.getCollectionName()).find(dboq).spliterator(), false).map(dbObject -> dbObject.get("_id").toString()).distinct().collect(toList());
final BasicDBObject itemsQuery = new BasicDBObject("parent", new BasicDBObject("$exists", false));
itemsQuery.put("launchRef", new BasicDBObject("$in", ids));
final List<String> itemIds = stream(mongoTemplate.getCollection("testItem").find(itemsQuery).spliterator(), false).map(dbObject -> dbObject.get("_id").toString()).collect(toList());
testItemRepository.delete(itemIds);
}
use of com.epam.ta.reportportal.database.entity.Launch in project commons-dao by reportportal.
the class LaunchRepositoryTest method findByProjectIdsData.
public List<Launch> findByProjectIdsData() {
final Launch launch1 = new Launch();
launch1.setProjectRef("project1");
launch1.setName("launch1");
final Launch launch2 = new Launch();
launch2.setProjectRef("project2");
launch2.setName("launch2");
final Launch launch3 = new Launch();
launch3.setProjectRef("project2");
launch3.setName("launch3");
final Launch launch4 = new Launch();
return launchRepository.save(asList(launch1, launch2, launch3, launch4));
}
Aggregations