private DateTimeFactory dateFactoryFor( StreamSequencerContext context ) { return context.getValueFactories().getDateFactory(); }
protected RequestProcessor( String sourceName, ExecutionContext context, Observer observer, DateTime now, CachePolicy defaultCachePolicy ) { CheckArg.isNotEmpty(sourceName, "sourceName"); CheckArg.isNotNull(context, "context"); this.context = context; this.sourceName = sourceName; this.nowInUtc = now != null ? now : context.getValueFactories().getDateFactory().createUtc(); this.defaultCachePolicy = defaultCachePolicy; this.changes = observer != null ? new LinkedList<ChangeRequest>() : null; this.observer = observer; }
protected String generateNonExistantWorkspaceName() { String workspaceName = "something bogus" + context.getValueFactories().getDateFactory().create().getString(); workspaceName = workspaceName.replaceAll(":",""); // get rid of colons, so the name is valid on Windows Set<String> workspaces = graph.getWorkspaces(); while (workspaces.contains(workspaceName)) { workspaceName = workspaceName + "1"; // keep appending '1' to the name, until it doesn't match } return workspaceName; }
this.doubleFactory = new Factory<Double>(valueFactories.getDoubleFactory()); this.decimalFactory = new Factory<BigDecimal>(valueFactories.getDecimalFactory()); this.dateFactory = new Factory<DateTime>(valueFactories.getDateFactory()) {
protected DateTime date( Object value ) { if (value instanceof Property) value = ((Property)value).getFirstValue(); return context.getValueFactories().getDateFactory().create(value); }
@Before public void beforeEach() { MockitoAnnotations.initMocks(this); sourceName = "MySource"; when(repository.getDefaultCachePolicy()).thenReturn(cachePolicy); when(repository.getSourceName()).thenReturn(sourceName); unknownRequests = new ArrayList<Request>(); context = new ExecutionContext(); now = context.getValueFactories().getDateFactory().create(); joinProcessor = new JoinRequestProcessorWithUnknownHandler(repository, context, now); joinQueue = new LinkedBlockingQueue<FederatedRequest>(); // Set up the projections ... mirrorProjection = new Projection("sourceA", "workspaceM", false, rules("/ => /")); projectionA = new Projection("sourceA", "workspaceA", false, rules("/a => /")); }
@Test public void shouldSerializeAndDeserializeDateTimeProperty() throws Exception { Property prop = createProperty("p1", valueFactories.getDateFactory().createUtc()); assertSerializableAndDeserializable(serializer, prop); assertThat(largeValues.getCount(), is(0)); prop = createProperty("p1", valueFactories.getDateFactory().create()); assertSerializableAndDeserializable(serializer, prop); assertThat(largeValues.getCount(), is(0)); }
nonExistantWorkspaceName = "Non-Existant Workspace"; context = new ExecutionContext(); now = context.getValueFactories().getDateFactory().create(); federatedRequests = new LinkedList<FederatedRequest>(); children = new ArrayList<ProjectedNode>();
final DateTime saveTime = context.getValueFactories().getDateFactory().create(); root.onChangedNodes(new LoadAllChildrenVisitor() { @Override
final Request request ) throws RepositorySourceException { DateTime nowInUtc = context.getValueFactories().getDateFactory().createUtc();
final DateTime saveTime = context.getValueFactories().getDateFactory().create(); root.onChangedNodes(new LoadAllChildrenVisitor() { @Override
@Before public void beforeEach() { problems = new SimpleProblems(); this.context = new ExecutionContext(); this.now = this.context.getValueFactories().getDateFactory().create(); this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories()); final SequencerOutputMap finalOutput = sequencerOutput; InMemoryRepositorySource source = new InMemoryRepositorySource(); source.setName(repositorySourceName); graph = Graph.create(source.getConnection(), context); this.streamSequencer = new StreamSequencer() { /** * This method always copies the {@link StreamSequencerAdapterTest#sequencerOutput} data into the output {@inheritDoc} * , and does nothing else with any of the other parameters. */ @Override public void sequence( InputStream stream, SequencerOutput output, StreamSequencerContext context ) { for (SequencerOutputMap.Entry entry : finalOutput) { Path nodePath = entry.getPath(); for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) { output.setProperty(nodePath, property.getName(), property.getValue()); } } } }; sequencer = new StreamSequencerAdapter(streamSequencer, false); seqContext = new SequencerContext(context, graph, graph, now); }
@Test public void shouldSetPropertyValueToPrimitiveTypes() { graph.set("propName").on(validPath).to(3.0F); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Float(3.0f))); graph.set("propName").on(validPath).to(1.0D); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Double(1.0))); graph.set("propName").on(validPath).to(false); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", Boolean.FALSE)); graph.set("propName").on(validPath).to(3); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Integer(3))); graph.set("propName").on(validPath).to(5L); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Long(5))); graph.set("propName").on(validPath).to(validPath); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", validPath)); graph.set("propName").on(validPath).to(validPath.getLastSegment().getName()); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", validPath.getLastSegment().getName())); Date now = new Date(); graph.set("propName").on(validPath).to(now); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", now)); DateTime dtNow = context.getValueFactories().getDateFactory().create(now); graph.set("propName").on(validPath).to(dtNow); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", dtNow)); Calendar calNow = Calendar.getInstance(); calNow.setTime(now); graph.set("propName").on(validPath).to(calNow); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", dtNow)); }