parent
717d69b979
commit
f189dd07a6
|
@ -94,14 +94,13 @@ public class UriHelperImpl implements UriHelper {
|
|||
result.append(Encoder.encode(value));
|
||||
} catch (final EdmPrimitiveTypeException e) {
|
||||
throw new SerializerException("Wrong key value!", e,
|
||||
SerializerException.MessageKeys.WRONG_PROPERTY_VALUE, edmProperty.getName(),
|
||||
propertyValue != null ? propertyValue.toString(): null);
|
||||
SerializerException.MessageKeys.WRONG_PROPERTY_VALUE, edmProperty.getName(), propertyValue.toString());
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private Object findPropertyRefValue(Entity entity, EdmKeyPropertyRef refType) throws SerializerException {
|
||||
private Object findPropertyRefValue(Entity entity, EdmKeyPropertyRef refType) {
|
||||
final int INDEX_ERROR_CODE = -1;
|
||||
final String propertyPath = refType.getName();
|
||||
String tmpPropertyName;
|
||||
|
@ -123,10 +122,6 @@ public class UriHelperImpl implements UriHelper {
|
|||
tmpPropertyName = propertyPath.substring(lastIndex, index);
|
||||
prop = findProperty(tmpPropertyName, prop.asComplex().getValue());
|
||||
}
|
||||
if (prop == null) {
|
||||
throw new SerializerException("Key Value Cannot be null for property: " + propertyPath,
|
||||
SerializerException.MessageKeys.WRONG_PROPERTY_VALUE, propertyPath);
|
||||
}
|
||||
return prop.getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,13 +18,9 @@
|
|||
*/
|
||||
package org.apache.olingo.server.core.uri;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.ValueType;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
|
||||
|
@ -36,9 +32,7 @@ import org.apache.olingo.server.api.uri.UriHelper;
|
|||
import org.apache.olingo.server.tecsvc.data.DataProvider;
|
||||
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class UriHelperTest {
|
||||
|
||||
|
@ -84,29 +78,4 @@ public class UriHelperTest {
|
|||
entity.getProperty("PropertyInt16").setValue(ValueType.PRIMITIVE, "wrong");
|
||||
helper.buildCanonicalURL(entitySet, entity);
|
||||
}
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedEx = ExpectedException.none();
|
||||
|
||||
@Test(expected = SerializerException.class)
|
||||
public void canonicalURLWithoutKeys() throws Exception {
|
||||
final EdmEntitySet entitySet = container.getEntitySet("ESAllPrim");
|
||||
Entity entity = data.readAll(entitySet).getEntities().get(0);
|
||||
List<Property> properties = entity.getProperties();
|
||||
properties.remove(0);
|
||||
helper.buildCanonicalURL(entitySet, entity);
|
||||
expectedEx.expect(SerializerException.class);
|
||||
expectedEx.expectMessage("Key Value Cannot be null for property: PropertyInt16");
|
||||
}
|
||||
|
||||
@Test(expected = SerializerException.class)
|
||||
public void canonicalURLWithKeyHavingNullValue() throws Exception {
|
||||
final EdmEntitySet entitySet = container.getEntitySet("ESAllPrim");
|
||||
Entity entity = data.readAll(entitySet).getEntities().get(0);
|
||||
Property property = entity.getProperties().get(0);
|
||||
property.setValue(property.getValueType(), null);
|
||||
helper.buildCanonicalURL(entitySet, entity);
|
||||
expectedEx.expect(SerializerException.class);
|
||||
expectedEx.expectMessage("Wrong key value!");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue