Package org.springframework.data.neo4j.model

Examples of org.springframework.data.neo4j.model.Person


    public Friendship friendShip2;
    public Friendship friendShip3;

    public SerialTesters createUpgraderTeam(GraphRepository<Person> repo, GraphRepository<Group> groupRepo, GraphRepository<Friendship> friendshipRepository)
    {
        emil = new Person("Emil", 30);

        michael = new Person("Michael", 36);
        michael.setBoss(emil);
        michael.setPersonality(Personality.EXTROVERT);
        michael.setLocation( 16, 56);

        david = new Person("David", 25);
        david.setBoss(emil);
        david.setLocation( 16.5, 56.5 );

        tareq = new Person("Tareq", 36);
        nicki = new Person("Nicki", 36);

        // Explicitly specify US locale for date parsing.  Otherwise, SimpleDateFormat
        // will use the default locale and we may get a parse exception, e.g.
        // French locale (fr_FR) does not recognize JAN a valid month.
        bdayFormatter = new SimpleDateFormat("dd MM yyyy HH:mm:ss", Locale.US);
View Full Code Here


   * @see DATAGRAPH-392
   */
  @Test
  public void adjustedWellKnownPagedFindAllMethodShouldReturnOnlyTheUserWithFirstnameOliver() {

    Person ollie = repository.save(new Person("Oliver", 30));
    repository.save(new Person("Thomas", 30));

    Page<Person> page = repository.findAll(new PageRequest(0, 2));

    assertThat(page.getNumberOfElements(), is(1));
    assertThat(page.getContent().get(0).getName(), is(ollie.getName()));
  }
View Full Code Here

   * @see DATAGRAPH-392
   */
  @Test
  public void adjustedWllKnownFindAllMethodShouldReturnAnEmptyList() {

    repository.save(new Person("Oliver", 30));
    repository.save(new Person("Thomas", 30));

    Result<Person> result = repository.findAll();

    assertThat(result.iterator().hasNext(), is(false));
  }
View Full Code Here

    }

    @Test
    public void shouldBeAbleToSerializeAndDeserializeBasicEntityGraph() throws Exception {
        Person person = personRepository.findOne(serialTesters.nicki.getId());
        assertEntityDetailsForPerson(person);
        assertThat(person, instanceOf(Serializable.class));

        // Do it
        byte[] bos = serializeIt(person);
        Person aDeserializedPerson = deserializeIt(bos);

        // Verify its the same
        assertEntityDetailsForPerson(aDeserializedPerson);
    }
View Full Code Here

        assertEntityDetailsForPerson(aDeserializedPerson);
    }

    @Test
    public void primitiveFieldShouldBeSerializedInOriginalForm() throws Exception {
        Person deserializedPerson = assertPreSerializationSetupThenGetDeserializedPerson();
        assertEquals(String.class, deserializedPerson.getName().getClass());
        assertEquals("Nicki", deserializedPerson.getName());
    }
View Full Code Here

        assertEquals("Nicki", deserializedPerson.getName());
    }

    @Test
    public void primitiveFieldUpdatedOnDeserializedEntityShouldBeAbleToBeSavedBackToRepo() throws Exception {
        final Person deserializedPerson = assertPreSerializationSetupThenGetDeserializedPerson();
        assertEquals(String.class, deserializedPerson.getName().getClass());
        assertEquals("Nicki", deserializedPerson.getName());

        deserializedPerson.setName("New Name");
        new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                personRepository.save(deserializedPerson);
            }
        });

        Person personFromDB = personRepository.findOne(deserializedPerson.getId());
        assertEquals("New Name", personFromDB.getName());
    }
View Full Code Here

        assertEquals("New Name", personFromDB.getName());
    }

    @Test
    public void managedFieldAkaRelationshipsShouldBeSerializedAsAHashSet() throws Exception {
        Person deserializedPerson = assertPreSerializationSetupThenGetDeserializedPerson();
        assertEquals(HashSet.class, deserializedPerson.getSerialFriends().getClass());
        assertEquals(1, deserializedPerson.getSerialFriends().size());
        assertThat(deserializedPerson.getSerialFriends(), hasItem(serialTesters.michael));
    }
View Full Code Here

        assertThat(deserializedPerson.getSerialFriends(), hasItem(serialTesters.michael));
    }

    @Test
    public void managedFieldAkaRelationshipUpdatedOnDeserializedEntityShouldBeAbleToBeSavedBackToRepo() throws Exception {
        final Person deserializedPerson = assertPreSerializationSetupThenGetDeserializedPerson();
        assertEquals(HashSet.class, deserializedPerson.getSerialFriends().getClass());
        assertEquals(1, deserializedPerson.getSerialFriends().size());
        assertThat(deserializedPerson.getSerialFriends(), hasItem(serialTesters.michael));

        deserializedPerson.addSerialFriend(serialTesters.david);
        assertEquals(2, deserializedPerson.getSerialFriends().size());
        new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                personRepository.save(deserializedPerson);
            }
        });

        Person personFromDB = personRepository.findOne(deserializedPerson.getId());
        assertEquals(2, personFromDB.getSerialFriends().size());
        assertThat(personFromDB.getSerialFriends(), hasItem(serialTesters.michael));
        assertThat(personFromDB.getSerialFriends(), hasItem(serialTesters.david));
    }
View Full Code Here

    }


    @Test
    public void dynamicPropertiesFieldShouldBeSerializedAsAPrefixedDynamicProperties() throws Exception {
        final Person deserializedPerson = assertPreSerializationSetupThenGetDeserializedPerson();
        assertEquals(PrefixedDynamicProperties.class, deserializedPerson.getPersonalProperties().getClass());
        assertEquals(2, deserializedPerson.getPersonalProperties().asMap().size());
        assertThat(asCollection( deserializedPerson.getPersonalProperties().getPropertyKeys()) , hasItems("addressLine1","addressLine2"));
    }
View Full Code Here

        assertThat(asCollection( deserializedPerson.getPersonalProperties().getPropertyKeys()) , hasItems("addressLine1","addressLine2"));
    }

    @Test
    public void dynamicPropertiesFieldUpdatedOnDeserializedEntityShouldBeAbleToBeSavedBackToRepo() throws Exception {
        final Person deserializedPerson = assertPreSerializationSetupThenGetDeserializedPerson();
        assertEquals(PrefixedDynamicProperties.class, deserializedPerson.getPersonalProperties().getClass());
        assertEquals(2, deserializedPerson.getPersonalProperties().asMap().size());
        assertThat(asCollection(deserializedPerson.getPersonalProperties().getPropertyKeys()) , hasItems("addressLine1", "addressLine2"));

        deserializedPerson.setProperty("newDynoProp", "newDynoValue");
        new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                personRepository.save(deserializedPerson);
            }
        });

        Person personFromDB = personRepository.findOne(deserializedPerson.getId());
        assertEquals(3, personFromDB.getPersonalProperties().asMap().size());
        assertThat(asCollection(personFromDB.getPersonalProperties().getPropertyKeys()) , hasItems("addressLine1", "addressLine2", "newDynoProp"));

    }
View Full Code Here

TOP

Related Classes of org.springframework.data.neo4j.model.Person

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.