fix #123 allow to specify extra annotations on repositories/methods
[yosql.git] / yosql-codegen / src / test / java / wtf / metio / yosql / codegen / blocks / DefaultCodeBlocksTest.java
blob50c3786e16cec300a780176c3b9e9325015353df
1 /*
2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
8 package wtf.metio.yosql.codegen.blocks;
10 import org.junit.jupiter.api.Assertions;
11 import org.junit.jupiter.api.BeforeEach;
12 import org.junit.jupiter.api.DisplayName;
13 import org.junit.jupiter.api.Test;
15 @DisplayName("DefaultCodeBlocks")
16 class DefaultCodeBlocksTest {
18 private CodeBlocks blocks;
20 @BeforeEach
21 void setUp() {
22 blocks = new DefaultCodeBlocks();
25 @Test
26 void returnTrue() {
27 Assertions.assertEquals("""
28 return true;
29 """, blocks.returnTrue().toString());
32 @Test
33 void returnFalse() {
34 Assertions.assertEquals("""
35 return false;
36 """, blocks.returnFalse().toString());
39 @Test
40 void initializeFieldToSelf() {
41 Assertions.assertEquals("""
42 this.name = name;
43 """, blocks.initializeFieldToSelf("name").toString());
46 @Test
47 void close() {
48 Assertions.assertEquals("""
49 resource.close();
50 """, blocks.close("resource").toString());
53 @Test
54 void returnValue() {
55 Assertions.assertEquals("""
56 return value;
57 """, blocks.returnValue(CodeBlocks.code("value")).toString());