use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class PatternValidatorTest method validateWithErrors.
private void validateWithErrors(final String value, final int expectedErrors) {
final Optional<AttributeValidationReport> reportOptional = VALIDATOR.validate(new AttributeImpl("test", value));
assertThat(reportOptional.get().getAttributeValidationViolations(), hasSize(expectedErrors));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class RangeValidatorTest method testWithinSmallDecimalRange.
@Test
public void testWithinSmallDecimalRange() {
final RangeValidator validator = new RangeValidator(new BigDecimal("1.2457515"), new BigDecimal("1.2487595"), new BigDecimal("1E-7"));
validateNoErrors(new AttributeImpl("", 1.2457515), validator);
validateNoErrors(new AttributeImpl("", 1.2487595), validator);
validateNoErrors(new AttributeImpl("", 1.246), validator);
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class SolrMetacardClientImpl method createMetacard.
public MetacardImpl createMetacard(SolrDocument doc) throws MetacardCreationException {
MetacardType metacardType = resolver.getMetacardType(doc);
MetacardImpl metacard = new MetacardImpl(metacardType);
for (String solrFieldName : doc.getFieldNames()) {
if (!resolver.isPrivateField(solrFieldName)) {
Collection<Object> fieldValues = doc.getFieldValues(solrFieldName);
Attribute attr = new AttributeImpl(resolver.resolveFieldName(solrFieldName), resolver.getDocValues(solrFieldName, fieldValues));
metacard.setAttribute(attr);
}
}
return metacard;
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class Jpeg2000ThumbnailConverterTest method testConversion.
@Test
public void testConversion() throws IOException, StopProcessingException, PluginExecutionException {
IIORegistry.getDefaultInstance().registerServiceProvider(jpeg2000ThumbnailConverter);
List<Result> resultList = new ArrayList<>();
Metacard metacard = new MetacardImpl();
byte[] j2kbytes = new byte[0];
resultList.add(new ResultImpl(metacard));
QueryResponseImpl queryResponse = new QueryResponseImpl(null, resultList, 1);
// there are two possible byte signatures, so test an example of each one
for (String image : new String[] { "/Bretagne2.j2k", "/Cevennes2.jp2" }) {
URL imageResource = Jpeg2000ThumbnailConverterTest.class.getResource(image);
if (imageResource == null) {
fail("The Image Resource came back null. Was the resources folder removed?");
}
String imageResourcePath = new File(imageResource.getFile()).getAbsolutePath();
j2kbytes = Files.readAllBytes(Paths.get(imageResourcePath));
metacard.setAttribute(new AttributeImpl(Metacard.THUMBNAIL, j2kbytes));
jpeg2000ThumbnailConverter.process(queryResponse);
// verify the plugin converted the j2k/jp2 image
assertTrue(!Arrays.equals(j2kbytes, metacard.getThumbnail()));
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
ImageIO.write(ImageIO.read(new ByteArrayInputStream(j2kbytes)), "gif", output);
metacard.setAttribute(new AttributeImpl(Metacard.THUMBNAIL, output.toByteArray()));
jpeg2000ThumbnailConverter.process(queryResponse);
// verify the plugin ignored the non-j2k
assertTrue(Arrays.equals(output.toByteArray(), metacard.getThumbnail()));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class TestExpirationDatePlugin method createMockMetacardsWithNoExpirationDate.
private List<Metacard> createMockMetacardsWithNoExpirationDate(int number) {
List<Metacard> mockMetacards = new ArrayList(number);
for (int i = 0; i < number; i++) {
Metacard mockMetacard = new MetacardImpl();
Attribute id = new AttributeImpl(Metacard.ID, Integer.toString(i));
mockMetacard.setAttribute(id);
Attribute title = new AttributeImpl(Metacard.TITLE, Integer.toString(i));
mockMetacard.setAttribute(title);
Attribute createdDate = new AttributeImpl(Core.METACARD_CREATED, CREATED_DATE.toDate());
mockMetacard.setAttribute(createdDate);
mockMetacards.add(mockMetacard);
}
return mockMetacards;
}
Aggregations