Skip to content

Podam doesn't randomize with proper accessors. #334

@onacit

Description

@onacit

It seems that podam does not randomize property with proper accessors.

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import uk.co.jemos.podam.api.PodamFactoryImpl;
import uk.co.jemos.podam.api.RandomDataProviderStrategyImpl;

import static org.assertj.core.api.Assertions.assertThat;

@Slf4j
class ZzzRemoveMe {

    @Test
    void __() {

        class Some {

            public Boolean getDef() {
                return def;
            }

            public void setDef(Boolean def) {
                this.def = def;
            }

            public Boolean getIsGhi() { // STANDARD getter of the `isGhi` field
                return isGhi;
            }

            public void setIsGhi(Boolean isGhi) { // STANDARD setter of the `isGhi` field
                isGhi = isGhi;
            }

            private Boolean def;

            private Boolean isGhi;
        }

        final var manufactured = new PodamFactoryImpl(new RandomDataProviderStrategyImpl()).manufacturePojo(Some.class);
        assertThat(manufactured.getDef())
                .as("def")
                .isNotNull();
        assertThat(manufactured.getIsGhi())
                .as("isGhi")
                .isNotNull();
    }
}

Adding non standard accessors doesn't help.

            public Boolean getGhi() { // Not a getter the the field; doesn't work anyway
                return isGhi;
            }

            public void setGhi(Boolean ghi) { // Not a setter for the field; doesn't work anyway
                isGhi = isGhi;
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions