@Test public void absentOptionalToMongoTest() { final RyaDetails details = RyaDetails.builder() .setRyaInstanceName("test") .setRyaVersion("1") .setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)) .setPCJIndexDetails( PCJIndexDetails.builder() .setEnabled(true) .setFluoDetails(new FluoDetails("fluo"))) .setTemporalIndexDetails(new TemporalIndexDetails(false)) .setFreeTextDetails(new FreeTextIndexDetails(true)) .setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())) .setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())) .build(); final Document actual = MongoDetailsAdapter.toDocument(details); final Document expected = Document.parse( "{ " + "instanceName : \"test\"," + "version : \"1\"," + "entityCentricDetails : true," + "pcjDetails : {" + "enabled : true," + "pcjs : [ ]" + "}," + "temporalDetails : false," + "freeTextDetails : true" + "}" ); assertEquals(expected, actual); }
public static Document toDocument(final RyaDetails details) { requireNonNull(details); final Document doc = new Document() .append(INSTANCE_KEY, details.getRyaInstanceName()) .append(VERSION_KEY, details.getRyaVersion()) .append(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()) .append(PCJ_DETAILS_KEY, toDocument(details.getPCJIndexDetails())) .append(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()) .append(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled()); if(details.getProspectorDetails().getLastUpdated().isPresent()) { doc.append(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get()); } if(details.getJoinSelectivityDetails().getLastUpdated().isPresent()) { doc.append(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get()); } if(details.getRyaStreamsDetails().isPresent()) { final RyaStreamsDetails ryaStreamsDetails = details.getRyaStreamsDetails().get(); final Document ryaStreamsFields = new Document() .append(RYA_STREAMS_HOSTNAME_KEY, ryaStreamsDetails.getHostname()) .append(RYA_STREAMS_PORT_KEY, ryaStreamsDetails.getPort()); doc.append(RYA_STREAMS_DETAILS_KEY, ryaStreamsFields); } return doc; }
MongoDetailsAdapter { public static Document toDocument(final RyaDetails details) { requireNonNull(details); final Document doc = new Document() .append(INSTANCE_KEY, details.getRyaInstanceName()) .append(VERSION_KEY, details.getRyaVersion()) .append(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()) .append(PCJ_DETAILS_KEY, toDocument(details.getPCJIndexDetails())) .append(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()) .append(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled()); if(details.getProspectorDetails().getLastUpdated().isPresent()) { doc.append(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get()); } if(details.getJoinSelectivityDetails().getLastUpdated().isPresent()) { doc.append(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get()); } if(details.getRyaStreamsDetails().isPresent()) { final RyaStreamsDetails ryaStreamsDetails = details.getRyaStreamsDetails().get(); final Document ryaStreamsFields = new Document() .append(RYA_STREAMS_HOSTNAME_KEY, ryaStreamsDetails.getHostname()) .append(RYA_STREAMS_PORT_KEY, ryaStreamsDetails.getPort()); doc.append(RYA_STREAMS_DETAILS_KEY, ryaStreamsFields); } return doc; } }
MongoDetailsAdapter { public static Document toDocument(final RyaDetails details) { requireNonNull(details); final Document doc = new Document() .append(INSTANCE_KEY, details.getRyaInstanceName()) .append(VERSION_KEY, details.getRyaVersion()) .append(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()) .append(PCJ_DETAILS_KEY, toDocument(details.getPCJIndexDetails())) .append(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()) .append(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled()); if(details.getProspectorDetails().getLastUpdated().isPresent()) { doc.append(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get()); } if(details.getJoinSelectivityDetails().getLastUpdated().isPresent()) { doc.append(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get()); } if(details.getRyaStreamsDetails().isPresent()) { final RyaStreamsDetails ryaStreamsDetails = details.getRyaStreamsDetails().get(); final Document ryaStreamsFields = new Document() .append(RYA_STREAMS_HOSTNAME_KEY, ryaStreamsDetails.getHostname()) .append(RYA_STREAMS_PORT_KEY, ryaStreamsDetails.getPort()); doc.append(RYA_STREAMS_DETAILS_KEY, ryaStreamsFields); } return doc; }  }
MongoDetailsAdapter { public static Document toDocument(final RyaDetails details) { requireNonNull(details); final Document doc = new Document() .append(INSTANCE_KEY, details.getRyaInstanceName()) .append(VERSION_KEY, details.getRyaVersion()) .append(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()) .append(PCJ_DETAILS_KEY, toDocument(details.getPCJIndexDetails())) .append(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()) .append(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled()); if(details.getProspectorDetails().getLastUpdated().isPresent()) { doc.append(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get()); } if(details.getJoinSelectivityDetails().getLastUpdated().isPresent()) { doc.append(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get()); } if(details.getRyaStreamsDetails().isPresent()) { final RyaStreamsDetails ryaStreamsDetails = details.getRyaStreamsDetails().get(); final Document ryaStreamsFields = new Document() .append(RYA_STREAMS_HOSTNAME_KEY, ryaStreamsDetails.getHostname()) .append(RYA_STREAMS_PORT_KEY, ryaStreamsDetails.getPort()); doc.append(RYA_STREAMS_DETAILS_KEY, ryaStreamsFields); } return doc; }  static Document toDocument(final RyaDetails details); static RyaDetails toRyaDetails(final Document doc); }
MongoDetailsAdapter { public static Document toDocument(final RyaDetails details) { requireNonNull(details); final Document doc = new Document() .append(INSTANCE_KEY, details.getRyaInstanceName()) .append(VERSION_KEY, details.getRyaVersion()) .append(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()) .append(PCJ_DETAILS_KEY, toDocument(details.getPCJIndexDetails())) .append(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()) .append(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled()); if(details.getProspectorDetails().getLastUpdated().isPresent()) { doc.append(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get()); } if(details.getJoinSelectivityDetails().getLastUpdated().isPresent()) { doc.append(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get()); } if(details.getRyaStreamsDetails().isPresent()) { final RyaStreamsDetails ryaStreamsDetails = details.getRyaStreamsDetails().get(); final Document ryaStreamsFields = new Document() .append(RYA_STREAMS_HOSTNAME_KEY, ryaStreamsDetails.getHostname()) .append(RYA_STREAMS_PORT_KEY, ryaStreamsDetails.getPort()); doc.append(RYA_STREAMS_DETAILS_KEY, ryaStreamsFields); } return doc; }  static Document toDocument(final RyaDetails details); static RyaDetails toRyaDetails(final Document doc); static final String INSTANCE_KEY; static final String VERSION_KEY; static final String ENTITY_DETAILS_KEY; static final String GEO_DETAILS_KEY; static final String PCJ_DETAILS_KEY; static final String PCJ_ENABLED_KEY; static final String PCJ_FLUO_KEY; static final String PCJ_PCJS_KEY; static final String PCJ_ID_KEY; static final String PCJ_UPDATE_STRAT_KEY; static final String PCJ_LAST_UPDATE_KEY; static final String TEMPORAL_DETAILS_KEY; static final String FREETEXT_DETAILS_KEY; static final String PROSPECTOR_DETAILS_KEY; static final String JOIN_SELECTIVITY_DETAILS_KEY; static final String RYA_STREAMS_DETAILS_KEY; static final String RYA_STREAMS_HOSTNAME_KEY; static final String RYA_STREAMS_PORT_KEY; }