@Test(expectedExceptions = IllegalArgumentException.class) public void testNullContentLengthIllegal() { AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null); Payload payload = Payloads.newStringPayload(""); payload.getContentMetadata().setContentLength(null); object.setPayload(payload); HttpRequest request = new HttpRequest("GET", URI.create("http://localhost")); binder.bindToRequest(request, object); }
public void testGood() { AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null); Payload payload = Payloads.newStringPayload(""); object.setPayload(payload); object.getUserMetadata().getListableMetadata().put("apple", "bear"); object.getUserMetadata().getListableMetadata().put("sushi", "king"); HttpRequest request = new HttpRequest("GET", URI.create("http://localhost")); request = binder.bindToRequest(request, object); assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king"); }
static { EXPECTED = Guice.createInjector() .getInstance(AtmosObject.Factory.class) .create( ParseSystemMetadataFromHeadersTest.EXPECTED, ParseUserMetadataFromHeadersTest.EXPECTED); EXPECTED.getContentMetadata().setName("e913e09366364e9ba384b8fead643d43"); EXPECTED.setPayload(RESPONSE.getPayload()); }
/** {@inheritDoc} */ @Override public int compareTo(AtmosObject o) { if (getContentMetadata().getName() == null) return -1; return (this == o) ? 0 : getContentMetadata().getName().compareTo(o.getContentMetadata().getName()); }
public MutableBlobMetadata apply(AtmosObject from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); to.setId(from.getSystemMetadata().getObjectID()); to.setLastModified(from.getSystemMetadata().getLastUserDataModification()); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setName(objectName.apply(from)); if (from.getSystemMetadata().getType() == FileType.DIRECTORY) { to.setType(StorageType.FOLDER); } else { to.setType(StorageType.BLOB); } Map<String, String> lowerKeyMetadata = Maps.newHashMap(); for (Entry<String, String> entry : from.getUserMetadata().getMetadata().entrySet()) { String key = entry.getKey().toLowerCase(); if (!systemMetadata.contains(key)) lowerKeyMetadata.put(key, entry.getValue()); } to.setUserMetadata(lowerKeyMetadata); return to; }