Search in sources :

Example 11 with FlaggedRelease

use of org.devgateway.ocds.persistence.mongo.FlaggedRelease in project ocvn by devgateway.

the class ReleaseFlaggingServiceTest method testI038.

@Test
public void testI038() {
    FlaggedRelease release1 = flaggedReleaseRepository.findByOcid("ocds-endpoint-001");
    Assert.assertNotNull(release1);
    Assert.assertEquals(false, release1.getFlags().getI038().getValue());
    Assert.assertEquals(true, release1.getFlags().getI038().getTypes().contains(FlagType.RIGGING));
    Assert.assertEquals(1, release1.getFlags().getI038().getTypes().size());
    FlaggedRelease release2 = flaggedReleaseRepository.findByOcid("ocds-endpoint-002");
    Assert.assertNotNull(release2);
    Assert.assertEquals(null, release2.getFlags().getI038().getValue());
    Assert.assertEquals(true, release2.getFlags().getI038().getTypes().contains(FlagType.RIGGING));
    Assert.assertEquals(1, release2.getFlags().getI038().getTypes().size());
}
Also used : FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease) Test(org.junit.Test)

Example 12 with FlaggedRelease

use of org.devgateway.ocds.persistence.mongo.FlaggedRelease in project ocvn by devgateway.

the class ReleaseFlaggingServiceTest method testI019.

@Test
public void testI019() {
    FlaggedRelease release1 = flaggedReleaseRepository.findByOcid("ocds-endpoint-001");
    Assert.assertNotNull(release1);
    Assert.assertEquals(true, release1.getFlags().getI019().getValue());
    Assert.assertEquals(true, release1.getFlags().getI019().getTypes().contains(FlagType.RIGGING));
    Assert.assertEquals(1, release1.getFlags().getI019().getTypes().size());
    FlaggedRelease release2 = flaggedReleaseRepository.findByOcid("ocds-endpoint-002");
    Assert.assertNotNull(release2);
    Assert.assertEquals(null, release2.getFlags().getI019().getValue());
    Assert.assertEquals(true, release2.getFlags().getI019().getTypes().contains(FlagType.RIGGING));
    Assert.assertEquals(1, release2.getFlags().getI019().getTypes().size());
}
Also used : FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease) Test(org.junit.Test)

Example 13 with FlaggedRelease

use of org.devgateway.ocds.persistence.mongo.FlaggedRelease in project ocvn by devgateway.

the class ReleaseFlaggingService method createStubFlagTypes.

/**
 * Sets flags on top of a stub empty release. This is just to populate the flags property.
 *
 * @return the flags property of {@link FlaggedRelease}
 */
public ReleaseFlags createStubFlagTypes() {
    FlaggedRelease fr = new FlaggedRelease();
    releaseFlagProcessors.forEach(processor -> processor.process(fr));
    return fr.getFlags();
}
Also used : FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease)

Example 14 with FlaggedRelease

use of org.devgateway.ocds.persistence.mongo.FlaggedRelease in project oc-explorer by devgateway.

the class ReleaseFlagI019Processor method calculateFlag.

@Override
protected Boolean calculateFlag(FlaggedRelease flaggable, StringBuffer rationale) {
    Optional<Award> award = flaggable.getAwards().stream().filter(a -> a.getDate() != null && Award.Status.active.equals(a.getStatus())).findFirst();
    if (!award.isPresent()) {
        return false;
    }
    Days daysBetween = Days.daysBetween(new DateTime(flaggable.getTender().getTenderPeriod().getEndDate()), new DateTime(award.get().getDate()));
    rationale.append("Days between: ").append(daysBetween.getDays()).append("; Max allowed days: ").append(MAX_ALLOWED_DAYS_TENDER_END_DATE_AWARD_DATE).append(";");
    return daysBetween.getDays() > MAX_ALLOWED_DAYS_TENDER_END_DATE_AWARD_DATE;
}
Also used : Flag(org.devgateway.ocds.persistence.mongo.flags.Flag) Arrays(java.util.Arrays) AbstractFlaggedReleaseFlagProcessor(org.devgateway.ocds.persistence.mongo.flags.AbstractFlaggedReleaseFlagProcessor) FlaggedReleasePredicates(org.devgateway.ocds.persistence.mongo.flags.preconditions.FlaggedReleasePredicates) DateTime(org.joda.time.DateTime) Set(java.util.Set) Award(org.devgateway.ocds.persistence.mongo.Award) FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease) HashSet(java.util.HashSet) Component(org.springframework.stereotype.Component) Days(org.joda.time.Days) PostConstruct(javax.annotation.PostConstruct) FlagType(org.devgateway.ocds.persistence.mongo.flags.FlagType) Optional(java.util.Optional) Collections(java.util.Collections) Award(org.devgateway.ocds.persistence.mongo.Award) Days(org.joda.time.Days) DateTime(org.joda.time.DateTime)

Example 15 with FlaggedRelease

use of org.devgateway.ocds.persistence.mongo.FlaggedRelease in project oc-explorer by devgateway.

the class ReleaseFlaggingServiceTest method testFlaggedEligibleTypes.

@Test
public void testFlaggedEligibleTypes() {
    FlaggedRelease release1 = flaggedReleaseRepository.findByOcid("ocds-endpoint-001");
    Assert.assertNotNull(release1);
    Assert.assertEquals(2, release1.getFlags().getFlaggedStats().stream().filter(f -> f.getType().equals(FlagType.RIGGING)).findFirst().get().getCount(), 0);
    Assert.assertEquals(5, release1.getFlags().getEligibleStats().stream().filter(f -> f.getType().equals(FlagType.RIGGING)).findFirst().get().getCount(), 0);
    FlaggedRelease release2 = flaggedReleaseRepository.findByOcid("ocds-endpoint-002");
    Assert.assertNotNull(release2);
    Assert.assertEquals(false, release2.getFlags().getFlaggedStats().stream().filter(f -> f.getType().equals(FlagType.RIGGING)).findFirst().isPresent());
    Assert.assertEquals(1, release2.getFlags().getEligibleStats().stream().filter(f -> f.getType().equals(FlagType.RIGGING)).findFirst().get().getCount(), 0);
}
Also used : ReleaseFlags(org.devgateway.ocds.persistence.mongo.flags.ReleaseFlags) ReleaseFlaggingService(org.devgateway.ocds.web.spring.ReleaseFlaggingService) FlagType(org.devgateway.ocds.persistence.mongo.flags.FlagType) Autowired(org.springframework.beans.factory.annotation.Autowired) FlaggedReleaseRepository(org.devgateway.ocds.persistence.mongo.repository.main.FlaggedReleaseRepository) Test(org.junit.Test) Assert(org.junit.Assert) FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease) Before(org.junit.Before) FlaggedRelease(org.devgateway.ocds.persistence.mongo.FlaggedRelease) Test(org.junit.Test)

Aggregations

FlaggedRelease (org.devgateway.ocds.persistence.mongo.FlaggedRelease)17 Test (org.junit.Test)13 FlagType (org.devgateway.ocds.persistence.mongo.flags.FlagType)4 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 Set (java.util.Set)2 PostConstruct (javax.annotation.PostConstruct)2 Award (org.devgateway.ocds.persistence.mongo.Award)2 AbstractFlaggedReleaseFlagProcessor (org.devgateway.ocds.persistence.mongo.flags.AbstractFlaggedReleaseFlagProcessor)2 Flag (org.devgateway.ocds.persistence.mongo.flags.Flag)2 ReleaseFlags (org.devgateway.ocds.persistence.mongo.flags.ReleaseFlags)2 FlaggedReleasePredicates (org.devgateway.ocds.persistence.mongo.flags.preconditions.FlaggedReleasePredicates)2 FlaggedReleaseRepository (org.devgateway.ocds.persistence.mongo.repository.main.FlaggedReleaseRepository)2 ReleaseFlaggingService (org.devgateway.ocds.web.spring.ReleaseFlaggingService)2 DateTime (org.joda.time.DateTime)2 Days (org.joda.time.Days)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2