Tests added looking into #35

This commit is contained in:
Jon Brisbin
2012-09-06 09:27:20 -05:00
committed by Jon Brisbin
parent 079f07b3fe
commit 4ece75b625
5 changed files with 85 additions and 4 deletions

View File

@@ -97,10 +97,7 @@ public class RepositoryAwareJacksonModule extends SimpleModule implements Initia
}
}
if(!conversionService.canConvert(domainType, Resource.class)) {
// Assign only if no custom converter already assigned
conversionService.addConverter(domainType, Resource.class, new EntityToResourceConverter(repoMeta));
}
conversionService.addConverter(domainType, Resource.class, new EntityToResourceConverter(repoMeta));
sers.addSerializer(domainType, new DomainObjectToResourceSerializer(domainType));
keySers.addSerializer(domainType, new DomainObjectToStringKeySerializer(domainType, repoMeta));

View File

@@ -0,0 +1,29 @@
package org.springframework.data.rest.test.webmvc;
import javax.persistence.Entity;
/**
* @author Jon Brisbin
*/
@Entity
public class Child extends Parent {
private String occupation;
public Child() {
}
public Child(String name, String occupation) {
super(name);
this.occupation = occupation;
}
public String getOccupation() {
return occupation;
}
public void setOccupation(String occupation) {
this.occupation = occupation;
}
}

View File

@@ -0,0 +1,9 @@
package org.springframework.data.rest.test.webmvc;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author Jon Brisbin
*/
public interface ChildRepository extends JpaRepository<Child, Long> {
}

View File

@@ -0,0 +1,37 @@
package org.springframework.data.rest.test.webmvc;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
/**
* @author Jon Brisbin
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Parent {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
public Parent() {
}
public Parent(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,9 @@
package org.springframework.data.rest.test.webmvc;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author Jon Brisbin
*/
public interface ParentRepository extends JpaRepository<Parent, Long> {
}