Package org.mongodb.morphia.mapping

Examples of org.mongodb.morphia.mapping.Mapper


    public JenkinsRule j = new JenkinsRule();

    @Before
    public void setupFongo() throws Exception {
        Morphia morphia = new Morphia();
        Mapper mapper = morphia.getMapper();
        mapper.getConverters().addConverter(new CopyOnWriteListConverter());
        mapper.getConverters().addConverter(new DescribableListConverter());
        mapper.getConverters().addConverter(new ParametersDefinitionPropertyCoverter());
        mapper.getConverters().addConverter(new CombinationConverter());
        mapper.getConverters().addConverter(new AxisListConverter());
        mapper.getConverters().addConverter(new ResultConverter());
        mapper.getOptions().setActLikeSerializer(true);
        mapper.getOptions().objectFactory = new CustomMorphiaObjectFactory(MongoRepository.class.getClassLoader());

        Datastore datastore = morphia.createDatastore(new Fongo(SetupConfig.get().getDbName()).getMongo(), SetupConfig.get().getDbName());

        Whitebox.setInternalState(MongoRepository.class, "datastore", datastore);
    }
View Full Code Here


        return datastore;
    }

    private Datastore configureDatastore() {
        Morphia morphia = new Morphia();
        Mapper mapper = morphia.getMapper();
        mapper.getConverters().addConverter(new CopyOnWriteListConverter());
        mapper.getConverters().addConverter(new DescribableListConverter());
        mapper.getConverters().addConverter(new ParametersDefinitionPropertyCoverter());
        mapper.getConverters().addConverter(new CombinationConverter());
        mapper.getConverters().addConverter(new AxisListConverter());
        mapper.getConverters().addConverter(new ResultConverter());


        mapper.getOptions().setActLikeSerializer(true);
        mapper.getOptions().objectFactory = new CustomMorphiaObjectFactory(Jenkins.getInstance().getPluginManager().uberClassLoader);

        Mongo mongo;

        try {
            mongo = new MongoClient(SetupConfig.get().getDbHost(), SetupConfig.get().getDbPort());
View Full Code Here

    @Test
    public void shouldNotErrorWhenValidateQueryCalledWithNullValue() {
        // this unit test is to drive fixing a null pointer in the logging code.  It's a bit stupid but it's an edge case that wasn't
        // caught.
        // when this is called, don't error
        validateQuery(SimpleEntity.class, new Mapper(), new StringBuilder("name"), EQUAL, null, true, true);
    }
View Full Code Here

    }

    @Test
    public void shouldNotAllowNonBooleanValuesForExistsOperator() {
        // given
        MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("name");
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, SimpleEntity.class, EXISTS, "value",
                                                          new ArrayList<ValidationFailure>()), is(false));
    }
View Full Code Here

    }

    @Test
    public void shouldAllowSizeOperatorForListTypesAndIntegerValues() {
        // given
        MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("listOfIntegers");

        // expect
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()),
                   is(true));
View Full Code Here

    }

    @Test
    public void shouldAllowSizeOperatorForArraysAndIntegerValues() {
        // given
        MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("arrayOfInts");

        // expect
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()),
                   is(true));
View Full Code Here

    @Test
    //this used to fail
    public void shouldAllowSizeOperatorForArrayListTypesAndIntegerValues() {
        // given
        MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("arrayListOfIntegers");

        // expect
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()),
                   is(true));
View Full Code Here

    }

    @Test
    public void shouldNotAllowSizeOperatorForNonListTypes() {
        // given
        MappedClass mappedClass = new MappedClass(EntityWithListsAndArrays.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("notAnArrayOrList");

        // expect
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, NullClass.class, SIZE, 3, new ArrayList<ValidationFailure>()),
                   is(false));
View Full Code Here

    }

    @Test
    public void shouldNotAllowSizeOperatorForNonIntegerValues() {
        // expect
        MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("name");
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, ArrayList.class, SIZE, "value", new ArrayList<ValidationFailure>()),
                   is(false));
    }
View Full Code Here

    }

    @Test
    public void shouldNotAllowOtherValuesForInOperator() {
        // expect
        MappedClass mappedClass = new MappedClass(SimpleEntity.class, new Mapper());
        MappedField mappedField = mappedClass.getMappedField("name");
        assertThat(QueryValidator.isCompatibleForOperator(mappedField, String.class, IN, "value", new ArrayList<ValidationFailure>()),
                   is(false));
    }
View Full Code Here

TOP

Related Classes of org.mongodb.morphia.mapping.Mapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.