<commit_before>/*
 * Copyright 2017 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.axway.ats.rbv;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.axway.ats.rbv.db.DbSearchTerm;
import com.axway.ats.rbv.db.DbStorage;
import com.axway.ats.rbv.db.MockDbProvider;
import com.axway.ats.rbv.db.rules.DbFieldsRule;
import com.axway.ats.rbv.db.rules.DbStringFieldRule;
import com.axway.ats.rbv.db.rules.DbStringFieldRule.MatchRelation;
import com.axway.ats.rbv.model.RbvException;
import com.axway.ats.rbv.model.RbvStorageException;
import com.axway.ats.rbv.storage.Matchable;

public class Test_SimpleMonitorListener extends BaseTest {
    /*
     * Test failures history:
     * - evaluateMonitorsOneMonitorPositive
     * - evaluateMonitorsOneMonitorPositiveRunTwice
     */
    private PollingParameters pollingParams;
    private Matchable         matchable;

    private static final int  POLLING_INTERVAL      = 1250;
    private static final int  POLLING_ATTEMPTS      = 5;

    private static final int  TIME_AFTER_START_POLL = 2 * POLLING_INTERVAL;               // time near of start of 3rd poll
    private static final int  TIME_END_POLL         = POLLING_ATTEMPTS * POLLING_INTERVAL;
    private static final int  TIME_BEFORE_END_POLL  = TIME_END_POLL - POLLING_INTERVAL;

    private MockDbProvider    mockDbProvider;

    @Before
    public void beforeMethod() throws RbvException {

        pollingParams = new PollingParameters(0, POLLING_INTERVAL, POLLING_ATTEMPTS);

        mockDbProvider = new MockDbProvider();
        DbStorage storage = new DbStorage(mockDbProvider);
        matchable = storage.getFolder(new DbSearchTerm(""));<commit_msg>[Unit][Rbv] Make Powermock and Log4j2 like each other<commit_after>/*
 * Copyright 2017-2021 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.axway.ats.rbv;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.powermock.core.classloader.annotations.PowerMockIgnore;

import com.axway.ats.rbv.db.DbSearchTerm;
import com.axway.ats.rbv.db.DbStorage;
import com.axway.ats.rbv.db.MockDbProvider;
import com.axway.ats.rbv.db.rules.DbFieldsRule;
import com.axway.ats.rbv.db.rules.DbStringFieldRule;
import com.axway.ats.rbv.db.rules.DbStringFieldRule.MatchRelation;
import com.axway.ats.rbv.model.RbvException;
import com.axway.ats.rbv.model.RbvStorageException;
import com.axway.ats.rbv.storage.Matchable;

@PowerMockIgnore("javax.management.*")
public class Test_SimpleMonitorListener extends BaseTest {
    /*
     * Test failures history:
     * - evaluateMonitorsOneMonitorPositive
     * - evaluateMonitorsOneMonitorPositiveRunTwice
     */
    private PollingParameters pollingParams;
    private Matchable         matchable;

    private static final int  POLLING_INTERVAL      = 1250;
    private static final int  POLLING_ATTEMPTS      = 5;

    private static final int  TIME_AFTER_START_POLL = 2 * POLLING_INTERVAL;               // time near of start of 3rd poll
    private static final int  TIME_END_POLL         = POLLING_ATTEMPTS * POLLING_INTERVAL;
    private static final int  TIME_BEFORE_END_POLL  = TIME_END_POLL - POLLING_INTERVAL;

    private MockDbProvider    mockDbProvider;

    @Before
    public void beforeMethod() throws RbvException {

        pollingParams = new PollingParameters(0, POLLING_INTERVAL, POLLING_ATTEMPTS);

        mockDbProvider = new MockDbProvider();
        DbStorage storage = new DbStorage(mockDbProvider);
        matchable = storage.getFolder(new DbSearchTerm(""));
{'fraction_non_alphanumeric': 0.08096280087527352, 'fraction_numerical': 0.007559180425701213, 'mean_word_length': 3.8768186226964114, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3109814', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1484, 'n_words': 415}