Skip to content

Commit

Permalink
Merge pull request #113 from LarryHsiao/constant_source
Browse files Browse the repository at this point in the history
Constant source
  • Loading branch information
LarryHsiao committed Mar 27, 2022
2 parents 49c5a6b + f62f8f6 commit 0ca2016
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/main/java/com/larryhsiao/clotho/ConstSource.java
@@ -0,0 +1,16 @@
package com.larryhsiao.clotho;

/**
* Constant source
*/
public class ConstSource<T> implements Source<T> {

private final T constant;

public ConstSource(T constant) {this.constant = constant;}

@Override
public T value() throws Exception {
return constant;
}
}
18 changes: 18 additions & 0 deletions src/test/java/com/larryhsiao/clotho/ConstSourceTest.java
@@ -0,0 +1,18 @@
package com.larryhsiao.clotho;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* Test for {@link ConstSource}.
*/
class ConstSourceTest {
@Test
void inputEqualsOutput() throws Exception {
final Object object = new Object();
Assertions.assertEquals(
object,
new ConstSource<>(object).value()
);
}
}

0 comments on commit 0ca2016

Please sign in to comment.