graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
batch.set(uriPropertyName).to(newUri).on(pathToNamespaceNode).and();
graph.set("refProp").on("/node1").to(graph.getNodeAt("/node1/node3")); graph.set("refProp").on("/node1/node1").to(graph.getNodeAt("/node3/node2")); // will soon be /node3/node2[1] graph.set("refProp").on("/node1/node2").to(graph.getNodeAt("/node2/node2")); graph.set("refProp").on("/node1/node3").to(graph.getNodeAt("/node2/node2")); graph.set("refProp").on("/node2/node1").to(graph.getNodeAt("/node1/node1")); graph.set("refProp").on("/node2/node3").to(graph.getNodeAt("/node1/node2")); graph.set("refProp").on("/node2/node2").to(graph.getNodeAt("/node2/node2/node1")); graph.set("refProp").on("/node2/node3/node1").to(graph.getNodeAt("/node2/node2/node1"));
configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:sources/source A").to(""); configRepository.set("retryLimit").on("/mode:sources/source A").to(3); configRepository.create("/mode:repositories/fed repos/mode:regions/source C").and(); configRepository.create("/mode:repositories/fed repos/mode:regions/source D").and(); configRepository.set(ModeShapeLexicon.TIME_TO_EXPIRE).on(fedReposPath).to(20000); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source A").to("/a/b/c => /sx/sy"); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source B").to("/ => /"); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source C").to("/d/e/f => /"); configRepository.set(ModeShapeLexicon.PROJECTION_RULES).on(fedReposPath + "mode:regions/source D").to("/ => /x/y/z");
graph.batch() .set("propA") .to("valueA") .on("/") .and()
graph.batch().set("description").on("/testnodeC/testnodeD").to("This is the value").and().execute();
configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A").to(""); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A/objectParam").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A/objectParam").to(""); configRepository.set("string").on("/mode:system/mode:sources/source A/objectParam").to("test string"); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source B/objectParam").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source B/objectParam").to(""); configRepository.set("string").on("/mode:system/mode:sources/source B/objectParam").to("test string"); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source B").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source B").to(""); configRepository.set("overloadedParam").on("/mode:system/mode:sources/source B").to("true");
graph.set("refProp").on("/refererringNode").to(graph.getNodeAt("/newUuids/node1/shouldBeRemoved"));
configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A").to(""); configRepository.set("retryLimit").on("/mode:system/mode:sources/source A").to(3); configRepository.set("intParam").on("/mode:system/mode:sources/source A").to("3"); configRepository.set("shortParam").on("/mode:system/mode:sources/source A").to("32"); configRepository.set("booleanParam").on("/mode:system/mode:sources/source A").to("true"); configRepository.set("stringParam").on("/mode:system/mode:sources/source A").to("string value"); configRepository.set("intArrayParam").on("/mode:system/mode:sources/source A").to("3"); configRepository.set("booleanArrayParam").on("/mode:system/mode:sources/source A").to("true"); configRepository.set("longObjectArrayParam").on("/mode:system/mode:sources/source A").to("987654321"); configRepository.set("booleanObjectArrayParam").on("/mode:system/mode:sources/source A").to("true"); configRepository.set("stringArrayParam").on("/mode:system/mode:sources/source A").to("string value");
graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
batch.set(actual.getName()).on(path).to(unionedValues).and();
batch.set("property6").to("new valid 6").on("/a"); batch.execute();
graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
@Test( expected = SequencerException.class ) public void shouldExecuteSequencerOnExistingNodeWithMissingSequencedPropertyAndOutputToExistingNode() throws Exception { // Set up the repository for the test ... graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.create("/d").and().create("/d/e").and(); Node nodeC = graph.getNodeAt("/a/b/c"); Node nodeE = graph.getNodeAt("/d/e"); assertThat(nodeC, is(notNullValue())); assertThat(nodeE, is(notNullValue())); assertThat(nodeE.getChildren().size(), is(0)); assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured")); // Set the property that will be sequenced ... // THIS TEST REQUIRES THIS PROPERTY TO BE NULL OR NON-EXISTANT graph.set("sequencedProperty").on(nodeC.getLocation()).to((String)null); // Set up the node changes ... Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = nodeC.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); // Set up the output directory ... Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); // Generate the output data that the sequencer subclass will produce and that should be saved to the repository ... sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); // Call the sequencer, which should cause the exception ... sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); }
@Test public void shouldExecuteSequencerOnExistingNodeAndOutputToExistingNode() throws Exception { // Set up the repository for the test ... graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.create("/d").and().create("/d/e").and(); graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes())); Node nodeC = graph.getNodeAt("/a/b/c"); Node nodeE = graph.getNodeAt("/d/e"); assertThat(nodeC, is(notNullValue())); assertThat(nodeE, is(notNullValue())); assertThat(nodeE.getChildren().size(), is(0)); assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured")); // Set the property that will be sequenced ... // Set up the node changes ... Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = nodeC.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); // Set up the output directory ... Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); // Generate the output data that the sequencer subclass will produce and that should be saved to the repository ... sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); // Call the sequencer ... sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); }
@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)); }
@Test public void shouldExecuteSequencerOnExistingNodeAndOutputToNonExistingNode() throws Exception { // Set up the repository for the test ... graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); // Set the property that will be sequenced ... graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes())); Node nodeC = graph.getNodeAt("/a/b/c"); assertThat(nodeC, is(notNullValue())); assertNodeDoesNotExist(graph, "/d"); // Set up the node changes ... Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = nodeC.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); // Set up the output directory ... Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); // Generate the output data that the sequencer subclass will produce and that should be saved to the repository ... sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); // Call the sequencer ... sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); // Check to see that the "/d/e" node has been created ... assertThat(graph.getNodeAt("/d/e"), is(notNullValue())); }
protected void testSequencer( final StreamSequencer sequencer ) throws Throwable { StreamSequencer streamSequencer = new StreamSequencer() { @Override public void sequence( InputStream stream, SequencerOutput output, StreamSequencerContext context ) { sequencer.sequence(stream, output, context); } }; StreamSequencerAdapter adapter = new StreamSequencerAdapter(streamSequencer); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.create("/d").and().create("/d/e").and(); graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes())); Node inputNode = graph.getNodeAt("/a/b/c"); Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = inputNode.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); adapter.execute(inputNode, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); }
@FixFor( "MODE-1168" ) @Test public void shouldUseCorrectSetterForOverloadedSimpleProperties() { Path configPath = context.getValueFactories().getPathFactory().create("/mode:system"); service = new RepositoryService(configRepositorySource, configWorkspaceName, configPath, context, bus, problems); // Set up the configuration repository ... configRepository.useWorkspace("default"); configRepository.create("/mode:system").and(); configRepository.create("/mode:system/mode:sources").and(); configRepository.create("/mode:system/mode:sources/source A").and(); final String className = FakeRepositorySource.class.getName(); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A").to(""); configRepository.set("overloadedParam").on("/mode:system/mode:sources/source A").to("true"); // Now, start up the service ... service.getAdministrator().start(); // Get the source, which should be configured ... RepositorySource repositorySourceA = service.getRepositoryLibrary().getSource("source A"); assertThat(repositorySourceA, is(instanceOf(FakeRepositorySource.class))); FakeRepositorySource sourceA = (FakeRepositorySource)repositorySourceA; assertThat(sourceA.isBooleanParam(), is(true)); }