package com.huatek.busi.ws.mock.epa;

import java.time.LocalDate;

import org.junit.Test;

import com.huatek.busi.ws.mock.AbstractMockTest;
import com.huatek.busi.ws.protocol.CacRequest;

/**
 * 油色谱数据模拟
 * 
 * @author anker_cheng
 * @date 2019/09/26
 */
public class EpaCacMockTest extends AbstractMockTest {
    static final int times = 10;
    private String sensorCodeList[] = {"BYQ20190919090901"};
    private String type = "021002";

    @Test
    public void uploadCACDataTest() {
        for (int i = 1; i <= 30; i++) {
            uploadCACDataTest(LocalDate.of(2019, 9, i), "A相");
        }
    }

    private void uploadCACDataTest(LocalDate date, String phase) {
        for (String sensorCode : sensorCodeList) {
            extracted(date, phase, sensorCode);
        }
    }

    private void extracted(LocalDate date, String phase, String sensorCode) {
        for (int i = 0; i < times; i++) {
            CacRequest request = newRequeset(sensorCode, type, date, phase);
            String[] vals = randomVal(12);
            addAttr(request, "Phase", phase);
            addAttr(request, "H2", vals[0]);
            addAttr(request, "CH4", vals[1]);
            addAttr(request, "C2H6", vals[2]);
            addAttr(request, "C2H4", vals[3]);
            addAttr(request, "C2H2", vals[4]);
            addAttr(request, "CO", vals[5]);
            addAttr(request, "CO2", vals[6]);
            addAttr(request, "H2O", vals[7]);
            addAttr(request, "O2", vals[8]);
            addAttr(request, "N2", vals[9]);
            addAttr(request, "GasPress", "");
            addAttr(request, "TotalHydrocarbon", vals[11]);
            client.uploadCACData(XSTREAM.toXML(request));
        }
    }
}
