Search in sources :

Example 6 with UpdatePolicy

use of org.javamoney.moneta.spi.LoaderService.UpdatePolicy in project jsr354-ri by JavaMoney.

the class LoadableResourceBuilderTest method setup.

@BeforeMethod
public void setup() throws URISyntaxException {
    String resourceId = "resourceId";
    UpdatePolicy updatePolicy = UpdatePolicy.LAZY;
    Map<String, String> properties = new HashMap<>();
    LoaderListener loaderListener = new LoaderListener() {

        @Override
        public void newDataLoaded(String resourceId, InputStream is) {
        }
    };
    URI backupResource = new URI("localhost");
    URI[] resourceLocations = new URI[] { new URI("localhost") };
    loadInformation = new LoadDataInformationBuilder().withResourceId(resourceId).withUpdatePolicy(updatePolicy).withProperties(properties).withLoaderListener(loaderListener).withBackupResource(backupResource).withResourceLocations(resourceLocations).build();
}
Also used : LoaderListener(org.javamoney.moneta.spi.LoaderService.LoaderListener) UpdatePolicy(org.javamoney.moneta.spi.LoaderService.UpdatePolicy) LoadDataInformationBuilder(org.javamoney.moneta.spi.LoadDataInformationBuilder) HashMap(java.util.HashMap) InputStream(java.io.InputStream) URI(java.net.URI) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with UpdatePolicy

use of org.javamoney.moneta.spi.LoaderService.UpdatePolicy in project jsr354-ri by JavaMoney.

the class LoadDataInformationBuilderTest method shouldReturnsErrorWhenResourceIdWasNotInformed.

@Test(expectedExceptions = IllegalStateException.class)
public void shouldReturnsErrorWhenResourceIdWasNotInformed() throws URISyntaxException {
    UpdatePolicy updatePolicy = UpdatePolicy.LAZY;
    Map<String, String> properties = new HashMap<>();
    LoaderListener loaderListener = new LoaderListener() {

        @Override
        public void newDataLoaded(String resourceId, InputStream is) {
        }
    };
    URI[] resourceLocations = new URI[] { new URI("localhost") };
    new LoadDataInformationBuilder().withUpdatePolicy(updatePolicy).withProperties(properties).withLoaderListener(loaderListener).withResourceLocations(resourceLocations).build();
}
Also used : LoaderListener(org.javamoney.moneta.spi.LoaderService.LoaderListener) UpdatePolicy(org.javamoney.moneta.spi.LoaderService.UpdatePolicy) HashMap(java.util.HashMap) InputStream(java.io.InputStream) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 8 with UpdatePolicy

use of org.javamoney.moneta.spi.LoaderService.UpdatePolicy in project jsr354-ri by JavaMoney.

the class LoadDataInformationBuilderTest method shouldCreateLoadDataInformationWithOutListener.

@Test
public void shouldCreateLoadDataInformationWithOutListener() throws URISyntaxException {
    String resourceId = "resourceId";
    UpdatePolicy updatePolicy = UpdatePolicy.LAZY;
    Map<String, String> properties = new HashMap<>();
    URI backupResource = new URI("localhost");
    URI[] resourceLocations = new URI[] { new URI("localhost") };
    LoadDataInformation loadInformation = new LoadDataInformationBuilder().withResourceId(resourceId).withUpdatePolicy(updatePolicy).withProperties(properties).withBackupResource(backupResource).withStartRemote(false).withResourceLocations(resourceLocations).build();
    assertEquals(loadInformation.getResourceId(), resourceId);
    assertEquals(loadInformation.getUpdatePolicy(), updatePolicy);
    assertEquals(loadInformation.getProperties(), properties);
    assertEquals(loadInformation.getBackupResource(), backupResource);
    assertEquals(loadInformation.getResourceLocations(), resourceLocations);
    assertFalse(loadInformation.isStartRemote());
}
Also used : UpdatePolicy(org.javamoney.moneta.spi.LoaderService.UpdatePolicy) HashMap(java.util.HashMap) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 9 with UpdatePolicy

use of org.javamoney.moneta.spi.LoaderService.UpdatePolicy in project jsr354-ri by JavaMoney.

the class LoadDataInformationBuilderTest method shouldReturnsErrorWhenPropertiesWasNotInformed.

@Test(expectedExceptions = IllegalStateException.class)
public void shouldReturnsErrorWhenPropertiesWasNotInformed() throws URISyntaxException {
    String resourceId = "resourceId";
    UpdatePolicy updatePolicy = UpdatePolicy.LAZY;
    LoaderListener loaderListener = new LoaderListener() {

        @Override
        public void newDataLoaded(String resourceId, InputStream is) {
        }
    };
    URI[] resourceLocations = new URI[] { new URI("localhost") };
    new LoadDataInformationBuilder().withResourceId(resourceId).withUpdatePolicy(updatePolicy).withLoaderListener(loaderListener).withResourceLocations(resourceLocations).build();
}
Also used : LoaderListener(org.javamoney.moneta.spi.LoaderService.LoaderListener) UpdatePolicy(org.javamoney.moneta.spi.LoaderService.UpdatePolicy) InputStream(java.io.InputStream) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

UpdatePolicy (org.javamoney.moneta.spi.LoaderService.UpdatePolicy)9 URI (java.net.URI)8 InputStream (java.io.InputStream)6 HashMap (java.util.HashMap)6 LoaderListener (org.javamoney.moneta.spi.LoaderService.LoaderListener)6 Test (org.testng.annotations.Test)6 LoadDataInformationBuilder (org.javamoney.moneta.spi.LoadDataInformationBuilder)3 LoadDataInformation (org.javamoney.moneta.spi.LoadDataInformation)2 BeforeMethod (org.testng.annotations.BeforeMethod)1