@Test(expected = ConversionException.class) public void testToDomainInvalidData() throws Exception { converter.toDomain(BinaryValue.create("test"), "application/x-protobuf"); }
@Override public NotificationListObject toDomain(final BinaryValue value, final String contentType) { if (!ProtocolBufferMediaType.APPLICATION_PROTOBUF.equals(contentType)) { LOGGER.error("Invalid Content-Type: {}", contentType); throw new ConversionException("Invalid Content-Type: " + contentType); } final NotificationListPB list; try { list = NotificationListPB.parseFrom(value.unsafeGetValue()); } catch (InvalidProtocolBufferException e) { LOGGER.error("Unable to convert value from Riak", e); throw new ConversionException(e); } final NotificationListObject obj = new NotificationListObject(); list.getNotificationList().stream() .map(NotificationListConverter::convert) .forEach(obj::addNotification); obj.deleteNotifications(list.getDeletedIdList()); return obj; }
NotificationListConverter extends Converter<NotificationListObject> { @Override public NotificationListObject toDomain(final BinaryValue value, final String contentType) { if (!ProtocolBufferMediaType.APPLICATION_PROTOBUF.equals(contentType)) { LOGGER.error("Invalid Content-Type: {}", contentType); throw new ConversionException("Invalid Content-Type: " + contentType); } final NotificationListPB list; try { list = NotificationListPB.parseFrom(value.unsafeGetValue()); } catch (InvalidProtocolBufferException e) { LOGGER.error("Unable to convert value from Riak", e); throw new ConversionException(e); } final NotificationListObject obj = new NotificationListObject(); list.getNotificationList().stream() .map(NotificationListConverter::convert) .forEach(obj::addNotification); obj.deleteNotifications(list.getDeletedIdList()); return obj; } }
NotificationListConverter extends Converter<NotificationListObject> { @Override public NotificationListObject toDomain(final BinaryValue value, final String contentType) { if (!ProtocolBufferMediaType.APPLICATION_PROTOBUF.equals(contentType)) { LOGGER.error("Invalid Content-Type: {}", contentType); throw new ConversionException("Invalid Content-Type: " + contentType); } final NotificationListPB list; try { list = NotificationListPB.parseFrom(value.unsafeGetValue()); } catch (InvalidProtocolBufferException e) { LOGGER.error("Unable to convert value from Riak", e); throw new ConversionException(e); } final NotificationListObject obj = new NotificationListObject(); list.getNotificationList().stream() .map(NotificationListConverter::convert) .forEach(obj::addNotification); obj.deleteNotifications(list.getDeletedIdList()); return obj; } NotificationListConverter(); }
NotificationListConverter extends Converter<NotificationListObject> { @Override public NotificationListObject toDomain(final BinaryValue value, final String contentType) { if (!ProtocolBufferMediaType.APPLICATION_PROTOBUF.equals(contentType)) { LOGGER.error("Invalid Content-Type: {}", contentType); throw new ConversionException("Invalid Content-Type: " + contentType); } final NotificationListPB list; try { list = NotificationListPB.parseFrom(value.unsafeGetValue()); } catch (InvalidProtocolBufferException e) { LOGGER.error("Unable to convert value from Riak", e); throw new ConversionException(e); } final NotificationListObject obj = new NotificationListObject(); list.getNotificationList().stream() .map(NotificationListConverter::convert) .forEach(obj::addNotification); obj.deleteNotifications(list.getDeletedIdList()); return obj; } NotificationListConverter(); @Override NotificationListObject toDomain(final BinaryValue value, final String contentType); @Override ContentAndType fromDomain(final NotificationListObject domainObject); }
NotificationListConverter extends Converter<NotificationListObject> { @Override public NotificationListObject toDomain(final BinaryValue value, final String contentType) { if (!ProtocolBufferMediaType.APPLICATION_PROTOBUF.equals(contentType)) { LOGGER.error("Invalid Content-Type: {}", contentType); throw new ConversionException("Invalid Content-Type: " + contentType); } final NotificationListPB list; try { list = NotificationListPB.parseFrom(value.unsafeGetValue()); } catch (InvalidProtocolBufferException e) { LOGGER.error("Unable to convert value from Riak", e); throw new ConversionException(e); } final NotificationListObject obj = new NotificationListObject(); list.getNotificationList().stream() .map(NotificationListConverter::convert) .forEach(obj::addNotification); obj.deleteNotifications(list.getDeletedIdList()); return obj; } NotificationListConverter(); @Override NotificationListObject toDomain(final BinaryValue value, final String contentType); @Override ContentAndType fromDomain(final NotificationListObject domainObject);  }