private static void testTransformation(final Transformation transformation) { MatcherAssert.assertThat(transformation.getUuid(), Matchers.equalTo("42")); MatcherAssert.assertThat(transformation.getFunctionType(), Matchers.equalTo(FunctionType.Transformation)); MatcherAssert.assertThat(transformation.getName(), Matchers.equalTo("transformation")); MatcherAssert.assertThat(transformation.getDescription(), Matchers.equalTo("transformation")); MatcherAssert.assertThat(transformation.getFunctionDescription(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(transformation.getParameters(), Matchers.hasSize(1)); MatcherAssert.assertThat(transformation.getParameters(), Matchers.hasItems("transformationInputString")); MatcherAssert.assertThat(transformation.getComponents(), Matchers.hasSize(3)); final Component c1 = CustomTransformationDeserializerTest.checkComponent(transformation, "1", "compose", "Add pre- or postfix to a string.", Lists.newArrayList("prefix", "postfix"), Tuple.tuple("inputString", "variable_name")); final Component c2 = CustomTransformationDeserializerTest.checkComponent(transformation, "2", "case", "Upper/lower-case transformation.", Lists.newArrayList("to", "language")); final Component c3 = CustomTransformationDeserializerTest .checkComponent(transformation, "3", "count", "Returns the an increasing count for each received literal.", Collections.<String>emptyList(), Tuple.tuple("inputString", "dataset")); // *C1* --> C2 MatcherAssert.assertThat(c1.getInputComponents(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(c1.getOutputComponents(), Matchers.hasSize(1)); MatcherAssert.assertThat(Iterators.getOnlyElement(c1.getOutputComponents().iterator()), Matchers.is(Matchers.sameInstance(c2))); // C1 --> *C2* MatcherAssert.assertThat(c2.getInputComponents(), Matchers.hasSize(1)); MatcherAssert.assertThat(c2.getOutputComponents(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(Iterators.getOnlyElement(c2.getInputComponents().iterator()), Matchers.is(Matchers.sameInstance(c1))); MatcherAssert.assertThat(c3.getInputComponents(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(c3.getOutputComponents(), Matchers.is(Matchers.nullValue())); }
/** * Create a new {@code Transformation} as a copy from a existing transformation with a specific id. <br> * <b>Use with care!</b> * <p> * This factory is to be used by {@link org.dswarm.persistence.model.job.utils.TransformationDeserializer} to avoid reflection * based access to a private/protected field, since the Json deserializer needs a way to set the id that was provided by the * JSON. * </p> * <p> * The id is otherwise assigned by the database/Hibernate layer. You should never need this outside of * {@code TransformationDeserializer}. * </p> * * @param transformation the base transformation that will be copied * @param uuid the target transformation's id value * @return a new transformation with the given id and all other attributes copied from the provided transformation. */ public static Transformation withId(final Transformation transformation, final String uuid) { final Transformation newTransformation = new Transformation(uuid); newTransformation.setComponents(transformation.getComponents()); newTransformation.setFunctionDescription(transformation.getFunctionDescription()); newTransformation.setParameters(transformation.getParameters()); newTransformation.setDescription(transformation.getDescription()); newTransformation.setName(transformation.getName()); return newTransformation; } }
Assert.assertNotNull("the transformation description shouldn't be null", transformation.getDescription()); Assert.assertEquals("the transformation descriptions are not equal", transformationDescription, transformation.getDescription()); Assert.assertEquals("the transformation parameters' size are not equal", 1, transformation.getParameters().size()); Assert.assertTrue("the transformation parameters doesn't contain transformation parameter '" + transformationParameter + "'", transformation
Assert.assertNotNull("the transformation description shouldn't be null", transformation.getDescription()); Assert.assertEquals("the transformation descriptions are not equal", transformationDescription, transformation.getDescription()); Assert.assertEquals("the transformation parameters' size are not equal", 1, transformation.getParameters().size()); Assert.assertTrue("the transformation parameters doesn't contain transformation parameter '" + transformationParameter + "'", transformation