Search in sources :

Example 1 with Step

use of net.thucydides.core.annotations.Step in project podam by devopsfolks.

the class ClassInfoValidationSteps method theClassInfoAttributesShouldMatchthePojoOnes.

@Step("Then the attributes contains in ClassInfo should match the ones contains in the POJO")
public void theClassInfoAttributesShouldMatchthePojoOnes(Set<String> attribs, Set<ClassAttribute> classAttributes) {
    Set<String> missingAttribs = new HashSet<String>(attribs);
    for (ClassAttribute attribute : classAttributes) {
        String attrName = attribute.getName();
        assertThat("Unexpected attribute", attrName, isIn(missingAttribs));
        missingAttribs.remove(attrName);
        Assert.assertEquals("Wrong number of getters for " + attribute.getName(), 1, attribute.getGetters().size());
        Assert.assertEquals("Wrong number of setters for " + attribute.getName(), 1, attribute.getSetters().size());
    }
    assertThat("Missing attributes", missingAttribs, is(empty()));
}
Also used : ClassAttribute(uk.co.jemos.podam.api.ClassAttribute) HashSet(java.util.HashSet) Step(net.thucydides.core.annotations.Step)

Example 2 with Step

use of net.thucydides.core.annotations.Step in project podam by devopsfolks.

the class PodamFactorySteps method givenAnAttributeMetadata.

@Step("Given an AttributeMetadata object")
public AttributeMetadata givenAnAttributeMetadata(Class<?> pojoClass, Object pojoInstance, Class<?> pojoType) {
    if (null == pojoClass) {
        throw new IllegalArgumentException("pojoClass cannot be null");
    }
    String attributeName = null;
    Class<?> realAttributeType = pojoType;
    Type realGenericType = pojoType;
    Type[] genericTypeArgs = new Type[0];
    List<Annotation> annotations = Collections.emptyList();
    AttributeMetadata attributeMetadata = new AttributeMetadata(attributeName, realAttributeType, realGenericType, genericTypeArgs, annotations, pojoClass, pojoInstance);
    return attributeMetadata;
}
Also used : Type(java.lang.reflect.Type) Annotation(java.lang.annotation.Annotation) Step(net.thucydides.core.annotations.Step)

Example 3 with Step

use of net.thucydides.core.annotations.Step in project podam by devopsfolks.

the class PodamStrategySteps method removeSpecific.

@Step("When I remove a specific type {1} for an abstract type or interface")
public <T> void removeSpecific(PodamFactory podamFactory, Class<T> abstractType) {
    DataProviderStrategy strategy = podamFactory.getStrategy();
    strategy.removeSpecific(abstractType);
}
Also used : DataProviderStrategy(uk.co.jemos.podam.api.DataProviderStrategy) Step(net.thucydides.core.annotations.Step)

Example 4 with Step

use of net.thucydides.core.annotations.Step in project tutorials by eugenp.

the class GithubRestUserAPISteps method getProfileOfUser.

@Step("When looking for {0} via the api")
public void getProfileOfUser(String username) throws IOException {
    HttpResponse httpResponse = getGithubUserProfile(api, username);
    resource = retrieveResourceFromResponse(httpResponse, GitHubUser.class);
}
Also used : HttpResponse(org.apache.http.HttpResponse) Step(net.thucydides.core.annotations.Step)

Example 5 with Step

use of net.thucydides.core.annotations.Step in project podam by devopsfolks.

the class OneDimentionalPojoValidationSteps method validateDimensionalTestPojo.

@Step("Then OneDimensionalTestPojo should be valid")
public void validateDimensionalTestPojo(OneDimensionalTestPojo pojo, DataProviderStrategy strategy) {
    assertThat("The boolean object field should have a value of TRUE", pojo.getBooleanObjectField(), equalTo(true));
    assertThat("The boolean field should have a value of TRUE", pojo.isBooleanField(), equalTo(true));
    byte byteField = pojo.getByteField();
    assertThat("The byte field should not be zero", byteField, not(equalTo((byte) 0)));
    Byte byteObjectField = pojo.getByteObjectField();
    assertThat("The Byte object field should not be zero", byteObjectField, not(equalTo((byte) 0)));
    short shortField = pojo.getShortField();
    assertThat("The short field should not be zero", shortField, not(equalTo((short) 0)));
    Short shortObjectField = pojo.getShortObjectField();
    assertThat("The Short Object field should not be zero", shortObjectField, not(equalTo((short) 0)));
    char charField = pojo.getCharField();
    assertThat("The char field should not be zero", charField, not(equalTo((char) 0)));
    Character characterObjectField = pojo.getCharObjectField();
    assertThat("The Character object field should not be zero", characterObjectField, not(equalTo((char) 0)));
    int intField = pojo.getIntField();
    assertThat("The int field cannot be zero", intField, not(equalTo(0)));
    Integer integerField = pojo.getIntObjectField();
    assertThat("The Integer object field cannot be zero", integerField, not(equalTo(0)));
    long longField = pojo.getLongField();
    assertThat("The long field cannot be zero", longField, not(equalTo(0L)));
    Long longObjectField = pojo.getLongObjectField();
    assertThat("The Long object field cannot be zero", longObjectField, not(equalTo(0L)));
    float floatField = pojo.getFloatField();
    assertThat("The float field cannot be zero", floatField, not(equalTo(0.0f)));
    Float floatObjectField = pojo.getFloatObjectField();
    assertThat("The Float object field cannot be zero", floatObjectField, not(equalTo(0.0f)));
    double doubleField = pojo.getDoubleField();
    assertThat("The double field cannot be zero", doubleField, not(equalTo(0.0d)));
    Double doubleObjectField = pojo.getDoubleObjectField();
    assertThat("The Double object field cannot be zero", doubleObjectField, not(equalTo(0.0d)));
    String stringField = pojo.getStringField();
    assertThat("The String field cannot be empty", stringField, not(isEmptyOrNullString()));
    Object objectField = pojo.getObjectField();
    Assert.assertNotNull("The Object field cannot be null", objectField);
    Calendar calendarField = pojo.getCalendarField();
    TypesUtils.checkCalendarIsValid(calendarField);
    Date dateField = pojo.getDateField();
    Assert.assertNotNull("The date field is not valid", dateField);
    Random[] randomArray = pojo.getRandomArray();
    Assert.assertNotNull("The array of Random objects cannot be null!", randomArray);
    Assert.assertEquals("The array of Random length should be one!", strategy.getNumberOfCollectionElements(Random.class), randomArray.length);
    Random random = randomArray[0];
    Assert.assertNotNull("The Random array element at [0] should not be null", random);
    int[] intArray = pojo.getIntArray();
    Assert.assertNotNull("The array of ints cannot be null!", intArray);
    Assert.assertEquals("The array of ints length should be the same as defined in the strategy!", strategy.getNumberOfCollectionElements(Integer.class), intArray.length);
    assertThat("The first element in the array of ints must be different from zero!", intArray[0], not(equalTo(0)));
    boolean[] booleanArray = pojo.getBooleanArray();
    Assert.assertNotNull("The array of booleans cannot be null!", booleanArray);
    Assert.assertEquals("The array of boolean length should be the same as the one set in the strategy!", strategy.getNumberOfCollectionElements(Boolean.class), booleanArray.length);
    BigDecimal bigDecimalField = pojo.getBigDecimalField();
    Assert.assertNotNull("The BigDecimal field cannot be null!", bigDecimalField);
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Random(java.util.Random) Step(net.thucydides.core.annotations.Step)

Aggregations

Step (net.thucydides.core.annotations.Step)12 Annotation (java.lang.annotation.Annotation)2 Type (java.lang.reflect.Type)2 Calendar (java.util.Calendar)2 DataProviderStrategy (uk.co.jemos.podam.api.DataProviderStrategy)2 CustomRandomDataProviderStrategy (uk.co.jemos.podam.test.strategies.CustomRandomDataProviderStrategy)2 CustomDataProviderStrategy (uk.co.jemos.podam.test.unit.features.inheritance.CustomDataProviderStrategy)2 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 HttpResponse (org.apache.http.HttpResponse)1 ClassAttribute (uk.co.jemos.podam.api.ClassAttribute)1 RecursivePojo (uk.co.jemos.podam.test.dto.RecursivePojo)1 Address (uk.co.jemos.podam.test.dto.docs.example.Address)1 BankAccount (uk.co.jemos.podam.test.dto.docs.example.BankAccount)1 Order (uk.co.jemos.podam.test.dto.docs.example.Order)1 OrderItem (uk.co.jemos.podam.test.dto.docs.example.OrderItem)1