Java Code Examples for org.camunda.spin.DataFormats#getDataFormat()

The following examples show how to use org.camunda.spin.DataFormats#getDataFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataFormatLoadingTest.java    From camunda-spin with Apache License 2.0 6 votes vote down vote up
@Test
@PrepareForTest(DataFormats.class)
public void testConfigureDataFormatWithConfiguratorList() {
  // given a custom data format provider that is returned by the service loader API
  mockProviders(new CustomDataFormatProvider());
  mockConfigurators();
  DataFormatConfigurator configurator = new ExampleCustomDataFormatConfigurator();

  // when a list of data format configurators is passed to the "load" method
  DataFormats.loadDataFormats(DataFormats.class.getClassLoader(),
                              Collections.singletonList(configurator));

  // then the configuration was applied
  ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) DataFormats
      .getDataFormat(CustomDataFormatProvider.NAME);
  assertThat(customFormat.getProperty())
      .isEqualTo(ExampleCustomDataFormatConfigurator.UPDATED_PROPERTY);
}
 
Example 2
Source File: DataFormatLoadingTest.java    From camunda-spin with Apache License 2.0 6 votes vote down vote up
@Test
@PrepareForTest(DataFormats.class)
public void testRegisterDataFormatWithConfiguratorList() {
  // given a custom data format provider that is returned by the service loader API
  mockProviders(new CustomDataFormatProvider());
  mockConfigurators();
  DataFormatConfigurator configurator = new ExampleCustomDataFormatConfigurator();

  // when a list of data format configurators is passed to the "load" method
  DataFormats.getInstance().registerDataFormats(DataFormats.class.getClassLoader(),
                                                Collections.singletonList(configurator));

  // then the configuration was applied
  ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) DataFormats
      .getDataFormat(CustomDataFormatProvider.NAME);
  assertThat(customFormat.getProperty())
      .isEqualTo(ExampleCustomDataFormatConfigurator.UPDATED_PROPERTY);
}
 
Example 3
Source File: SpinFactoryImpl.java    From camunda-spin with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends Spin<?>> T createSpin(Object parameter, String dataFormatName) {
  ensureNotNull("dataFormatName", dataFormatName);

  DataFormat<T> dataFormat = (DataFormat<T>) DataFormats.getDataFormat(dataFormatName);

  return createSpin(parameter, dataFormat);
}
 
Example 4
Source File: DataFormatLoadingTest.java    From camunda-spin with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest( { DataFormats.class })
public void testCustomDataFormatProvider() {
  // given a custom data format provider that is returned by the service loader API
  mockProviders(new CustomDataFormatProvider());
  mockConfigurators();

  // when the custom data format is requested
  DataFormat<?> customDataFormat = DataFormats.getDataFormat(CustomDataFormatProvider.NAME);

  // then it should be properly returned
  assertThat(customDataFormat).isNotNull();
  assertThat(customDataFormat).isSameAs(CustomDataFormatProvider.DATA_FORMAT);
}
 
Example 5
Source File: DataFormatLoadingTest.java    From camunda-spin with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest( { DataFormats.class })
public void testConfigureDataFormat() {
  // given a custom data format provider that is returned by the service loader API
  mockProviders(new CustomDataFormatProvider());
  mockConfigurators(new ExampleCustomDataFormatConfigurator());

  DataFormat<?> format = DataFormats.getDataFormat(CustomDataFormatProvider.NAME);
  assertThat(format).isSameAs(CustomDataFormatProvider.DATA_FORMAT);

  // then the configuration was applied
  ExampleCustomDataFormat customFormat = (ExampleCustomDataFormat) format;
  assertThat(customFormat.getProperty()).isEqualTo(ExampleCustomDataFormatConfigurator.UPDATED_PROPERTY);
}
 
Example 6
Source File: SpinValueImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public DataFormat<? extends Spin<?>> getDataFormat() {
  if(isDeserialized) {
    return DataFormats.getDataFormat(dataFormatName);
  }
  else {
    throw new IllegalStateException("Spin value is not deserialized.");
  }
}