Search in sources :

Example 1 with PublishedPointService

use of com.infiniteautomation.mango.spring.service.PublishedPointService in project ma-core-public by infiniteautomation.

the class MangoTestBase method createMockPublisher.

/**
 * Create a publisher with points
 */
public MockPublisherVO createMockPublisher(boolean enabled, List<MockPublishedPointVO> points) {
    MockPublisherVO publisherVO = (MockPublisherVO) ModuleRegistry.getPublisherDefinition(MockPublisherDefinition.TYPE_NAME).baseCreatePublisherVO();
    publisherVO.setName(UUID.randomUUID().toString());
    publisherVO.setEnabled(enabled);
    PublisherService publisherService = Common.getBean(PublisherService.class);
    try {
        MockPublisherVO pub = (MockPublisherVO) publisherService.insert(publisherVO);
        PublishedPointService publishedPointService = Common.getBean(PublishedPointService.class);
        for (MockPublishedPointVO point : points) {
            publishedPointService.insert(point);
        }
        return pub;
    } catch (ValidationException e) {
        fail(e.getValidationErrorMessage(Common.getTranslations()));
        return null;
    }
}
Also used : ValidationException(com.infiniteautomation.mango.util.exception.ValidationException) PublisherService(com.infiniteautomation.mango.spring.service.PublisherService) PublishedPointService(com.infiniteautomation.mango.spring.service.PublishedPointService) MockPublisherVO(com.serotonin.m2m2.vo.publish.mock.MockPublisherVO) MockPublishedPointVO(com.serotonin.m2m2.vo.publish.mock.MockPublishedPointVO)

Example 2 with PublishedPointService

use of com.infiniteautomation.mango.spring.service.PublishedPointService in project ma-core-public by infiniteautomation.

the class MangoTestBase method createMockPublishedPoint.

/**
 * Create a published point
 */
public MockPublishedPointVO createMockPublishedPoint(MockPublisherVO publisher, IDataPoint dataPoint, boolean enabled) {
    MockPublishedPointVO pp = publisher.getDefinition().createPublishedPointVO(publisher, dataPoint);
    pp.setName(dataPoint.getName());
    pp.setEnabled(true);
    PublishedPointService publishedPointService = Common.getBean(PublishedPointService.class);
    try {
        publishedPointService.insert(pp);
    } catch (ValidationException e) {
        fail(e.getValidationErrorMessage(Common.getTranslations()));
        return null;
    }
    return pp;
}
Also used : ValidationException(com.infiniteautomation.mango.util.exception.ValidationException) PublishedPointService(com.infiniteautomation.mango.spring.service.PublishedPointService) MockPublishedPointVO(com.serotonin.m2m2.vo.publish.mock.MockPublishedPointVO)

Aggregations

PublishedPointService (com.infiniteautomation.mango.spring.service.PublishedPointService)2 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)2 MockPublishedPointVO (com.serotonin.m2m2.vo.publish.mock.MockPublishedPointVO)2 PublisherService (com.infiniteautomation.mango.spring.service.PublisherService)1 MockPublisherVO (com.serotonin.m2m2.vo.publish.mock.MockPublisherVO)1