| 1 |
package ezvcard.property.asserter; |
| 2 |
|
| 3 |
import static ezvcard.util.TestUtils.assertIntEquals; |
| 4 |
import static org.junit.Assert.assertEquals; |
| 5 |
import static org.junit.Assert.assertNull; |
| 6 |
|
| 7 |
import java.util.List; |
| 8 |
|
| 9 |
import ezvcard.parameter.MediaTypeParameter; |
| 10 |
import ezvcard.property.BinaryProperty; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
@SuppressWarnings("rawtypes") |
| 45 |
public class BinaryPropertyAsserter<T extends BinaryProperty> extends PropertyAsserter<BinaryPropertyAsserter<T>, T> { |
| 46 |
private MediaTypeParameter contentType; |
| 47 |
private Integer dataLength; |
| 48 |
private String url; |
| 49 |
|
| 50 |
public BinaryPropertyAsserter(List<T> properties, VCardAsserter asserter) { |
| 51 |
super(properties, asserter); |
| 52 |
} |
| 53 |
|
| 54 |
public BinaryPropertyAsserter<T> contentType(MediaTypeParameter contentType) { |
| 55 |
this.contentType = contentType; |
| 56 |
return this_; |
| 57 |
} |
| 58 |
|
| 59 |
public BinaryPropertyAsserter<T> dataLength(int dataLength) { |
| 60 |
this.dataLength = dataLength; |
| 61 |
return this_; |
| 62 |
} |
| 63 |
|
| 64 |
public BinaryPropertyAsserter<T> url(String url) { |
| 65 |
this.url = url; |
| 66 |
return this_; |
| 67 |
} |
| 68 |
|
| 69 |
@Override |
| 70 |
protected void _run(T property) { |
| 71 |
assertEquals(contentType, property.getContentType()); |
| 72 |
|
| 73 |
if (dataLength == null) { |
| 74 |
assertNull(property.getData()); |
| 75 |
} else { |
| 76 |
assertIntEquals(dataLength, property.getData().length); |
| 77 |
} |
| 78 |
|
| 79 |
assertEquals(url, property.getUrl()); |
| 80 |
} |
| 81 |
|
| 82 |
@Override |
| 83 |
protected void _reset() { |
| 84 |
contentType = null; |
| 85 |
dataLength = null; |
| 86 |
url = null; |
| 87 |
} |
| 88 |
} |