本文整理汇总了Java中org.edgexfoundry.domain.core.Reading.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Reading.setId方法的具体用法?Java Reading.setId怎么用?Java Reading.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.edgexfoundry.domain.core.Reading
的用法示例。
在下文中一共展示了Reading.setId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
* Add a new reading. ServiceException (HTTP 503) for unknown or unanticipated issues.
* DataValidationException if the associated value descriptor is non-existent.
*
* @param reading - Reading object
* @return String id (database id) of the new Reading
* @throws ServiceException (HTTP 503) for unknown or unanticipated issues
* @throws DataValidationException (HTTP 409) if one of the readings associated to the new event
* contains a non-existent value descriptor.
*/
@RequestMapping(method = RequestMethod.POST)
@Override
public String add(@RequestBody Reading reading) {
if (valDescRepos.findByName(reading.getName()) == null)
throw new DataValidationException("Non-existent value descriptor specified in reading");
try {
if (persistData) {
readingRepos.save(reading);
} else
reading.setId("unsaved");
return reading.getId();
} catch (Exception e) {
logger.error("Error adding reading: " + e.getMessage());
throw new ServiceException(e);
}
}
示例2: testUpdate
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Test
public void testUpdate() {
Reading reading2 = new Reading(TEST_NAME, "newvalue");
reading2.setOrigin(1234);
reading2.setId(testReadingId);
assertTrue("Reading controller unable to update reading", controller.update(reading2));
Reading reading = repos.findOne(testReadingId);
assertEquals("Reading ID does not match saved id", testReadingId, reading.getId());
assertEquals("Reading name does not match saved name", TEST_NAME, reading.getName());
assertEquals("Reading value does not match saved name", "newvalue", reading.getValue());
assertEquals("Reading origin does not match saved origin", 1234, reading.getOrigin());
assertNotNull("Reading modified date is null", reading.getModified());
assertNotNull("Reading create date is null", reading.getCreated());
assertTrue(reading.getModified() != reading.getCreated());
}
示例3: getTestEvent
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
private Event getTestEvent() {
List<Reading> readings = null;
readings = new ArrayList<Reading>();
Reading reading = new Reading();
reading.setName("test_valueAlias");
reading.setValue("test_value");
reading.setCreated(0);
reading.setDevice(EdgeOpcUaCommon.DEFAULT_ENDPOINT.getValue());
reading.setModified(0);
reading.setId("id1");
reading.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
reading.setPushed(new Timestamp(System.currentTimeMillis()).getTime());
readings.add(reading);
Event event = new Event(EdgeOpcUaCommon.DEFAULT_ENDPOINT.getValue(), readings);
event.setCreated(0);
event.setModified(0);
event.setId("id1");
event.markPushed(new Timestamp(System.currentTimeMillis()).getTime());
event.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
return event;
}
示例4: testUpdateException
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Test(expected = ServiceException.class)
public void testUpdateException() throws Exception {
unsetControllerRepos();
Reading reading = new Reading();
reading.setId(testReadingId);
controller.update(reading);
}
示例5: testUpdateWithBadName
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Test(expected = DataValidationException.class)
public void testUpdateWithBadName() {
Reading reading = new Reading("unknownname", "somevalue");
reading.setId(testReadingId);
reading.setOrigin(TEST_ORIGIN);
controller.update(reading);
}
示例6: getEvent
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
* get Event Object. Name is set as provider key called ValueAlias. And Device is set as
* endpointUri of opcua server. And others will be set as default value.
*
* @fn Event getEvent(EdgeMessage data)
*/
private Event getEvent(EdgeMessage data) {
if (null == data) {
return null;
}
List<Reading> readings = null;
readings = new ArrayList<Reading>();
Reading reading = new Reading();
reading.setName(data.getResponses().get(0).getEdgeNodeInfo().getValueAlias());
reading.setValue(data.getResponses().get(0).getMessage().getValue().toString());
reading.setCreated(0);
reading.setDevice(data.getEdgeEndpointInfo().getEndpointUri());
reading.setModified(0);
reading.setId("id1");
reading.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
reading.setPushed(new Timestamp(System.currentTimeMillis()).getTime());
readings.add(reading);
Event event = new Event(data.getEdgeEndpointInfo().getEndpointUri(), readings);
event.setCreated(0);
event.setModified(0);
event.setId("id1");
event.markPushed(new Timestamp(System.currentTimeMillis()).getTime());
event.setOrigin(new Timestamp(System.currentTimeMillis()).getTime());
return event;
}
示例7: testUpdateWithUnknownId
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Test(expected = NotFoundException.class)
public void testUpdateWithUnknownId() {
Reading reading = new Reading();
reading.setId("unknownId");
controller.update(reading);
}