package cz.senslog.analytics.utils.validator;

import cz.senslog.analytics.domain.*;
import cz.senslog.analytics.domain.ComparisonOperator;
import org.junit.jupiter.api.Test;

import java.util.List;

class OnChangeNotifyTriggerTest {

    @Test
    void value_true_time_true() {
        Threshold th = new Threshold(1, 1, true, true, true,null, List.of(
                ThresholdDimension.of(1, NotifyTrigger.Mode.ON_CHANGE, AttributeType.VAL, List.of(
                        ThresholdDimensionRule.of(ComparisonOperator.GE, 25)
                )),
                ThresholdDimension.of(2, NotifyTrigger.Mode.INSTANT, AttributeType.TIME, List.of(
                        ThresholdDimensionRule.of(ComparisonOperator.GE, 43200),
                        ThresholdDimensionRule.of(ComparisonOperator.LE, 54000)
                ))
        ));

/*
        NotifyTrigger notifyTrigger = th.notifyTriggerMode().createInstance();

        ValidationResult vr1 = new ValidationResult(AttributeType.VAL, 25.1);
        vr1.addViolatedRule(ComparisonOperator.GE, 25);

        ValidationResult vr2 = new ValidationResult(AttributeType.TIME, 43200);
        vr2.addViolatedRule(ComparisonOperator.GE, 43200);
        vr2.addViolatedRule(ComparisonOperator.LE, 54000);

        notifyTrigger.accept(th, vr1, vr2);

        assertTrue(notifyTrigger.shouldNotify());

        ValidationReport validationReport = notifyTrigger.resultsToNotify();
        assertFalse(validationReport.isEmpty());
        assertTrue(Strings.isBlank(validationReport.message()));

        assertEquals(validationReport.validationResults().length, 2);

 */
    }

    @Test
    void value_false_time_true() {
        Threshold th = new Threshold(1, 1, true, true, true, null, List.of(
                ThresholdDimension.of(1, NotifyTrigger.Mode.ON_CHANGE, AttributeType.VAL, List.of(
                        ThresholdDimensionRule.of(ComparisonOperator.GE, 25)
                )),
                ThresholdDimension.of(2, NotifyTrigger.Mode.INSTANT, AttributeType.TIME, List.of(
                        ThresholdDimensionRule.of(ComparisonOperator.GE, 43200),
                        ThresholdDimensionRule.of(ComparisonOperator.LE, 54000)
                ))
        ));


        /*
        NotifyTrigger notifyTrigger = th.notifyTriggerMode().createInstance();

        ValidationResult vr1 = new ValidationResult(AttributeType.VAL, 24.9);

        ValidationResult vr2 = new ValidationResult(AttributeType.TIME, 43200);
        vr2.addViolatedRule(ComparisonOperator.GE, 43200);
        vr2.addViolatedRule(ComparisonOperator.LE, 54000);

        notifyTrigger.accept(th, vr1, vr2);

        assertFalse(notifyTrigger.shouldNotify());
        assertTrue(notifyTrigger.resultsToNotify().isEmpty());

         */
    }
}