Search in sources :

Example 1 with RunIfEnabled

use of com.qcadoo.plugin.api.RunIfEnabled in project mes by qcadoo.

the class UnusedContextsCleanUpServiceTest method shouldBeAnnotatedWithRunIfEnabled.

@Test
public final void shouldBeAnnotatedWithRunIfEnabled() throws NoSuchMethodException {
    RunIfEnabled runIfEnabledAnnotation = getPerformCleanUpMethod().getAnnotation(RunIfEnabled.class);
    Assert.assertNotNull("class should be annotated with @RunIfEnabled!", runIfEnabledAnnotation);
    Assert.assertArrayEquals(new String[] { TechnologiesGeneratorConstants.PLUGIN_IDENTIFIER }, runIfEnabledAnnotation.value());
}
Also used : RunIfEnabled(com.qcadoo.plugin.api.RunIfEnabled) Test(org.junit.Test)

Example 2 with RunIfEnabled

use of com.qcadoo.plugin.api.RunIfEnabled in project mes by qcadoo.

the class UnusedContextsCleanUpService method performCleanUp.

@Async
@Scheduled(cron = CRON_EVERYDAY_AT_5AM)
@RunIfEnabled(TechnologiesGeneratorConstants.PLUGIN_IDENTIFIER)
public void performCleanUp() {
    DateTime threshold = DateTime.now().minusWeeks(1);
    Either<EntityMessagesHolder, List<ContextId>> result = generatorContextDataProvider.deleteContextsNotUsedSince(threshold);
    if (result.isLeft()) {
        warn(String.format("CleanUp aborted - Technology generator context couldn't be deleted: %s", result.getLeft()));
    } else {
        info(String.format("CleanUp done - %s technology generator contexts were deleted.", result.getRight().size()));
    }
}
Also used : List(java.util.List) DateTime(org.joda.time.DateTime) EntityMessagesHolder(com.qcadoo.model.api.EntityMessagesHolder) Scheduled(org.springframework.scheduling.annotation.Scheduled) Async(org.springframework.scheduling.annotation.Async) RunIfEnabled(com.qcadoo.plugin.api.RunIfEnabled)

Example 3 with RunIfEnabled

use of com.qcadoo.plugin.api.RunIfEnabled in project mes by qcadoo.

the class DeliveryStateValidationAspectTest method shouldBeAnnotatedWithAspectAndRunIfEnabledAnnotations.

@Test
public final void shouldBeAnnotatedWithAspectAndRunIfEnabledAnnotations() {
    assertEquals("com.qcadoo.mes.deliveries.states.aop.listeners.DeliveryStateValidationAspect", clazz.getCanonicalName());
    assertNotNull(clazz.getAnnotation(Aspect.class));
    RunIfEnabled runIfEnabled = clazz.getAnnotation(RunIfEnabled.class);
    assertNotNull(runIfEnabled);
    String runIfEnabledPliginIdentifier = runIfEnabled.value()[0];
    assertEquals(DeliveriesConstants.PLUGIN_IDENTIFIER, runIfEnabledPliginIdentifier);
}
Also used : RunIfEnabled(com.qcadoo.plugin.api.RunIfEnabled) DeliveryStateValidationAspect(com.qcadoo.mes.deliveries.states.aop.listeners.DeliveryStateValidationAspect) Aspect(org.aspectj.lang.annotation.Aspect) Test(org.junit.Test)

Example 4 with RunIfEnabled

use of com.qcadoo.plugin.api.RunIfEnabled in project mes by qcadoo.

the class ExportToPdfControllerOOverrideAspectTest method checkAspectAnnotations.

@Test
public final void checkAspectAnnotations() {
    Class<?> clazz = ExportToPdfControllerOOverrideAspect.class;
    assertNotNull(clazz.getAnnotation(Aspect.class));
    RunIfEnabled runIfEnabledAnnotation = clazz.getAnnotation(RunIfEnabled.class);
    assertEquals(OrdersConstants.PLUGIN_IDENTIFIER, runIfEnabledAnnotation.value()[0]);
}
Also used : RunIfEnabled(com.qcadoo.plugin.api.RunIfEnabled) Aspect(org.aspectj.lang.annotation.Aspect) Test(org.junit.Test)

Aggregations

RunIfEnabled (com.qcadoo.plugin.api.RunIfEnabled)4 Test (org.junit.Test)3 Aspect (org.aspectj.lang.annotation.Aspect)2 DeliveryStateValidationAspect (com.qcadoo.mes.deliveries.states.aop.listeners.DeliveryStateValidationAspect)1 EntityMessagesHolder (com.qcadoo.model.api.EntityMessagesHolder)1 List (java.util.List)1 DateTime (org.joda.time.DateTime)1 Async (org.springframework.scheduling.annotation.Async)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1