Search in sources :

Example 1 with EasyRandomParameters

use of org.jeasy.random.EasyRandomParameters in project operatorfabric-core by opfab.

the class CardProcessServiceShould method instantiateRandomCardGenerator.

@NotNull
private EasyRandom instantiateRandomCardGenerator() {
    LocalDate today = LocalDate.now();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    LocalTime nine = LocalTime.of(9, 0);
    LocalTime fifteen = LocalTime.of(17, 0);
    EasyRandomParameters parameters = new EasyRandomParameters().seed(5467L).objectPoolSize(100).randomizationDepth(3).charset(forName("UTF-8")).timeRange(nine, fifteen).dateRange(today, tomorrow).stringLengthRange(5, 50).collectionSizeRange(1, 10).excludeField(named("data")).excludeField(named("parameters")).excludeField(named("timeSpans")).scanClasspathForConcreteTypes(true).overrideDefaultInitialization(false).ignoreRandomizationErrors(true);
    return new EasyRandom(parameters);
}
Also used : LocalTime(java.time.LocalTime) EasyRandomParameters(org.jeasy.random.EasyRandomParameters) LocalDate(java.time.LocalDate) EasyRandom(org.jeasy.random.EasyRandom) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with EasyRandomParameters

use of org.jeasy.random.EasyRandomParameters in project mule-wsc-connector by mulesoft.

the class ConfigEqualsTestCase method testReliableMessagingNotEquals.

@Test
public void testReliableMessagingNotEquals() {
    EasyRandomParameters parameters = new EasyRandomParameters();
    parameters.collectionSizeRange(1, 3);
    EasyRandom factory = new EasyRandom(parameters);
    ReliableMessagingConfiguration reliableMessaging = factory.nextObject(ReliableMessagingConfiguration.class);
    assertThat(reliableMessaging, is(notNullValue()));
    assertThat(reliableMessaging, not(equalTo(new Object())));
}
Also used : EasyRandomParameters(org.jeasy.random.EasyRandomParameters) ReliableMessagingConfiguration(org.mule.extension.ws.api.reliablemessaging.ReliableMessagingConfiguration) EasyRandom(org.jeasy.random.EasyRandom) Test(org.junit.Test)

Example 3 with EasyRandomParameters

use of org.jeasy.random.EasyRandomParameters in project mule-wsc-connector by mulesoft.

the class ConfigEqualsTestCase method testAddressingEquals.

@Test
public void testAddressingEquals() {
    EasyRandomParameters parameters = new EasyRandomParameters();
    parameters.collectionSizeRange(1, 3);
    EasyRandom factory = new EasyRandom(parameters);
    EasyRandom factory2 = new EasyRandom(parameters);
    for (int i = 0; i < 1000; i++) {
        AddressingConfiguration addressingConfiguration = factory.nextObject(AddressingConfiguration.class);
        AddressingConfiguration clonedAddressingConfiguration = factory2.nextObject(AddressingConfiguration.class);
        assertThat(addressingConfiguration, is(addressingConfiguration));
        assertThat(clonedAddressingConfiguration, is(clonedAddressingConfiguration));
        assertThat(addressingConfiguration, is(clonedAddressingConfiguration));
        assertThat(addressingConfiguration.hashCode(), is(clonedAddressingConfiguration.hashCode()));
    }
}
Also used : EasyRandomParameters(org.jeasy.random.EasyRandomParameters) AddressingConfiguration(org.mule.extension.ws.api.addressing.AddressingConfiguration) EasyRandom(org.jeasy.random.EasyRandom) Test(org.junit.Test)

Example 4 with EasyRandomParameters

use of org.jeasy.random.EasyRandomParameters in project mule-wsc-connector by mulesoft.

the class ConfigEqualsTestCase method testAddressingNotEquals.

@Test
public void testAddressingNotEquals() {
    EasyRandomParameters parameters = new EasyRandomParameters();
    parameters.collectionSizeRange(1, 3);
    EasyRandom factory = new EasyRandom(parameters);
    AddressingConfiguration addressingConfiguration = factory.nextObject(AddressingConfiguration.class);
    assertThat(addressingConfiguration, is(notNullValue()));
    assertThat(addressingConfiguration, not(equalTo(new Object())));
}
Also used : EasyRandomParameters(org.jeasy.random.EasyRandomParameters) AddressingConfiguration(org.mule.extension.ws.api.addressing.AddressingConfiguration) EasyRandom(org.jeasy.random.EasyRandom) Test(org.junit.Test)

Example 5 with EasyRandomParameters

use of org.jeasy.random.EasyRandomParameters in project mule-wsc-connector by mulesoft.

the class ConfigEqualsTestCase method testCustomTransportsEquals.

@Test
public void testCustomTransportsEquals() {
    EasyRandomParameters parameters = new EasyRandomParameters();
    parameters.collectionSizeRange(1, 3);
    EasyRandom factory = new EasyRandom(parameters);
    EasyRandom factory2 = new EasyRandom(parameters);
    for (int i = 0; i < 1000; i++) {
        CustomTransportConfiguration customTransport = factory.nextObject(CustomHttpTransportConfiguration.class);
        CustomTransportConfiguration anotherCustomTransport = factory.nextObject(DefaultHttpTransportConfiguration.class);
        CustomTransportConfiguration clonedCustomTransport = factory2.nextObject(CustomHttpTransportConfiguration.class);
        CustomTransportConfiguration anotherClonedCustomTransport = factory2.nextObject(DefaultHttpTransportConfiguration.class);
        assertThat(customTransport, is(clonedCustomTransport));
        assertThat(customTransport.hashCode(), is(clonedCustomTransport.hashCode()));
        assertThat(anotherCustomTransport, is(anotherClonedCustomTransport));
        assertThat(anotherCustomTransport.hashCode(), is(anotherClonedCustomTransport.hashCode()));
        assertThat(customTransport, not(anotherCustomTransport));
        assertThat(customTransport.hashCode(), not(anotherCustomTransport.hashCode()));
        assertThat(clonedCustomTransport, not(anotherClonedCustomTransport));
        assertThat(clonedCustomTransport.hashCode(), not(anotherClonedCustomTransport.hashCode()));
    }
}
Also used : EasyRandomParameters(org.jeasy.random.EasyRandomParameters) CustomTransportConfiguration(org.mule.extension.ws.api.transport.CustomTransportConfiguration) EasyRandom(org.jeasy.random.EasyRandom) Test(org.junit.Test)

Aggregations

EasyRandom (org.jeasy.random.EasyRandom)13 EasyRandomParameters (org.jeasy.random.EasyRandomParameters)13 Test (org.junit.Test)10 LocalDate (java.time.LocalDate)3 LocalTime (java.time.LocalTime)3 NotNull (org.jetbrains.annotations.NotNull)3 ReliableMessagingConfiguration (org.mule.extension.ws.api.reliablemessaging.ReliableMessagingConfiguration)3 AddressingConfiguration (org.mule.extension.ws.api.addressing.AddressingConfiguration)2 ReliableMessagingConnectionSettings (org.mule.extension.ws.api.reliablemessaging.ReliableMessagingConnectionSettings)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 Charset.forName (java.nio.charset.Charset.forName)1 Instant (java.time.Instant)1 ZoneOffset (java.time.ZoneOffset)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1