Comments (5)
I tried to reproduce it by making classes from the code above, but was unable to.
The problem seems related to enums somehow. Could you please tell me which of the dummy classes below is an enum in your model, or maybe which of these classes contain enums in turn, maybe as inherited members?
How do you initialize your Product? I tried to make OptionType an enum and wrote this test, which unfortunately succeeds:
@Test
public void convertsClassWithoutTerms() throws IOException {
final Product product = new Product();
product.addOptionType(OptionType.BAR);
mapper.writeValue(w, product);
assertEquals("{\"@context\":{\"@vocab\":\"http://schema.org/\"," +
"\"inventoryOnHand\":\"http://www.soluvas.org/commerceplug/1.0#inventoryOnHand\"}," +
"\"@type\":\"Product\"," +
"\"optionTypes\":[\"BAR\"]}",
w.toString());
}
Dummy classes I created:
public class Action {}
public class ImageObject {}
public interface IThing {
void setThingId(String id);
List<String> getAdditionalTypes();
String getAlternateName();
String getDescription();
ImageObject getImage();
String getName();
Action getPotentialAction();
String getSameAs();
String getUrl();
}
public interface IProduct {
OrganizationOrBrand getBrand();
void setBrand(OrganizationOrBrand brand);
Organization getManufacturer();
void setManufacturer(Organization manufacturer);
String getSku();
void setSku(String sku);
String getBarcode();
void setBarcode(String barcode);
CurrencyUnit getPriceCurrency();
void setPriceCurrency(CurrencyUnit currency);
BigDecimal getPrice();
void setPrice(BigDecimal price);
DecimalMeasure<Mass> getWeight();
void setWeight(DecimalMeasure<Mass> weight);
DecimalMeasure<Length> getDepth();
void setDepth(DecimalMeasure<Length> depth);
DecimalMeasure<Length> getWidth();
void setWidth(DecimalMeasure<Length> width);
DecimalMeasure<Length> getHeight();
void setHeight(DecimalMeasure<Length> height);
IColor getColor();
void setColor(IColor color);
BigDecimal getProductionCost();
void setProductionCost(BigDecimal productionCost);
DecimalMeasure<Quantity> getInventoryLevel();
void setInventoryLevel(DecimalMeasure<Quantity> inventoryLevel);
DecimalMeasure<Quantity> getInventoryOnHand();
void setInventoryOnHand(DecimalMeasure<Quantity> inventoryOnHand);
List<OptionType> getOptionTypes();
List<Product> getVariants();
String getSerialNumber();
void setSerialNumber(String serialNumber);
List<PropertyValue<?>> getAdditionalProperties();
}
public class OrganizationOrBrand {}
public class Organization {}
public class CurrencyUnit {}
public class Mass {}
public class Length {}
public class DecimalMeasure<T> {}
public class IColor {}
public class InventoryManagement {}
public class InventoryPolicy {}
public class Quantity {}
public enum OptionType { FOO, BAR }
public class PropertyValue<T> {}
from hydra-java.
I was able to reproduce this now, in combination with #7. No need to give more details at the moment.
from hydra-java.
Is it possible that in your test case the availability
in Offer
is null? That is the reason why my test case fails now, after solving the accessibility problem. When I use setAvailability
to assign a value, the test runs through.
The serializer should of course ignore null values for enum members and not throw an exception.
from hydra-java.
Yes, uninitialized enums are null
by default. These are part of current work developing CommercePlug API which uses Hydra (and this project hydra-java in order to render). Thanks for developing this library @dschulten :)
from hydra-java.
Solved in 0.2.0-SNAPSHOT
from hydra-java.
Related Issues (20)
- Allow clients to request expanded, compacted and flattened representation
- Handle incoming json-ld in expanded form
- Affordance rendered as templated in application/json although params are optional
- path segment variables should not be prefixed with /
- Add Uber Spring MVC message converter
- Support terms with object values in context HOT 1
- Make revs in Affordance an ignored json property
- Using hydra-java without Spring HOT 1
- Issue generating links off of request mapping in parent class HOT 1
- Spike for hal-forms HOT 1
- Move to Java 8 and Spring 4.x HOT 1
- Consider moving this project to an organization, possibly new name
- SpringBoot AutoConfiguration support and Hydra SpringBoot Starter HOT 1
- AffordanceBuilderFactory does not use value of a @RequestParam HOT 1
- I suppose this project is dead, yes? HOT 1
- Issue with traverson HOT 1
- AffordanceBuilder GET methods not listed HOT 3
- Using the Affordance Builder with a null HttpServletRequest HOT 3
- Support Spring @DateTimeFormat
- Support Spring HATEOAS 1.0.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hydra-java.