Skip to content

Commit

Permalink
added some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jexenberger committed Jun 25, 2014
1 parent 3e455e7 commit 06c50dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/test/java/org/yadi/core/MyObject.java
Expand Up @@ -92,6 +92,10 @@ public void run() {
System.out.println("hello world");
}

public void start() {
System.out.println("started");
}

@Override
public Integer get() {
run();
Expand Down
23 changes: 17 additions & 6 deletions src/test/java/org/yadi/core/ObjectDefinitionTest.java
Expand Up @@ -17,9 +17,7 @@

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

/**
* Created by julian3 on 2014/05/01.
Expand All @@ -29,6 +27,21 @@ public class ObjectDefinitionTest {

public static final String HELLLOOOO = "helllloooo";


@Test
public void testSimple() throws Exception {
MyObject result = new ObjectDefinition<MyObject>()
.type(MyObject.class)
.set((myObject, value)-> myObject.setA(value), "hello world")
.create();

result = new ObjectDefinition<MyObject>()
.type(MyObject.class)
.set(MyObject::setA, "hello world")
.create();

}

@Test
public void testDefine() throws Exception {

Expand All @@ -41,7 +54,7 @@ public void testDefine() throws Exception {
.destroyWith(MyObject::DESTROY)
.initWith(MyObject::afterPropertiesSet)
.set(MyObject::setA, "hello world")
.bind(MyObject::setC, ()-> HELLLOOOO)
.bind(MyObject::setC, () -> HELLLOOOO)
.bind(MyObject::setB, MyObject::aValue);

MyObject result = objectDefinition.create();
Expand All @@ -52,8 +65,6 @@ public void testDefine() throws Exception {
assertTrue(result.isAfterProps());




}

@Test
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/org/yadi/core/SamplesTest.java
Expand Up @@ -14,12 +14,15 @@ public class SamplesTest {
public void testSimpleString() throws Exception {

Container container = create((builder) -> {
builder
.define(String.class)
builder.define(String.class)
.args("hello world");

builder.define(MyObject.class)
.set(MyObject::setA,"hello world")
.initWith(MyObject::start);
});
String myString = container.get(String.class);
System.out.println("An non-empty string: " + myString);
MyObject myString = container.get(MyObject.class);
System.out.println("An non-empty string: " + myString.get());

}

Expand Down

0 comments on commit 06c50dc

Please sign in to comment.