Search in sources :

Example 1 with PublisherService

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

the class MangoTestBase method createMockPublisher.

/**
 * Create a publisher
 */
public MockPublisherVO createMockPublisher(boolean enabled) {
    MockPublisherVO publisherVO = (MockPublisherVO) ModuleRegistry.getPublisherDefinition(MockPublisherDefinition.TYPE_NAME).baseCreatePublisherVO();
    publisherVO.setName(UUID.randomUUID().toString());
    publisherVO.setEnabled(enabled);
    PublisherService publisherService = Common.getBean(PublisherService.class);
    try {
        return (MockPublisherVO) publisherService.insert(publisherVO);
    } 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) MockPublisherVO(com.serotonin.m2m2.vo.publish.mock.MockPublisherVO)

Example 2 with PublisherService

use of com.infiniteautomation.mango.spring.service.PublisherService 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)

Aggregations

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