package com.szpg.db.test; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import com.szpg.db.dao.PgAcuRdcmdDao; import com.szpg.db.dao.impl.PgAcuRdcmdDaoImpl; import com.szpg.db.data.PgAcuRdcmd; import com.szpg.plc.message.AppMessageConstants; import com.szpg.plc.message.command.ReadMemoryCommand; import com.szpg.plc.util.ByteUtil; import com.szpg.util.Configure; public class PgAcuRdcmdDaoTest { private PgAcuRdcmdDao dao; @Before public void init() { dao = new PgAcuRdcmdDaoImpl(); } // @Test public void testAdd() { ReadMemoryCommand ch4 = ReadMemoryCommand.getInstance(AppMessageConstants.CMD_TYPE_READCH4STATUS); ch4.setDestinationId("006B00"); ch4.setMessageProducerId("00F400"); ch4.setMemoryArea((byte) 0x31); ch4.setStartAddress("001A00"); ch4.setCountWord(Integer.parseInt(Configure.getProperty("acubl", "YXL.ACU001.CHALM.WORDCOUNT"))); ch4.setCountBit(Integer.parseInt(Configure.getProperty("acubl", "YXL.ACU001.CHALM.BITCOUNT"))); PgAcuRdcmd cmd = new PgAcuRdcmd(); cmd.setId(ch4.getId()); cmd.setTm(ch4.getTime().getTime()); cmd.setCmd_type(ch4.getCommandType()); cmd.setDest(ch4.getDestinationId()); cmd.setMem_area_cd(ByteUtil.binToHexString(new byte[] {ch4.getMemoryArea()})); cmd.setStart_mem_word(ch4.getStartAddress().substring(0, 4)); cmd.setStart_mem_bit(ch4.getStartAddress().substring(4)); cmd.setCount_word(ch4.getCountWord()); cmd.setCount_bit(ch4.getCountBit()); assertEquals(1, dao.addCmdRecord(cmd)); } @Test public void testFindAll() { assertEquals(1, dao.findAll().size()); } @Test public void testFindByDestAndCount() { assertEquals("12", dao.findLatestCmdByDestAndCount("006B00", 1).getCmd_type()); } // @Test public void testUpdateResponsed() { assertEquals(1, dao.updateCmdRecordResponsed("23ff9e2987e64f248823254f0dfe1528")); } }