Skip to content

Commit

Permalink
refactor: testing builder API #4
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 8, 2022
1 parent 622af34 commit 121bedc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fkl_cli/src/deconstruct/model_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl ModelBuilder {

match ext {
"java" => {
let mut file = Self::by_str(path);
let mut file = Self::by_str(ModelBuilder::read_content(path).as_str());
file.path = ModelBuilder::format_path(path);
file.file_name = file_name.to_string();
file.pure_name = file_name.replace(".java", "");
Expand All @@ -57,8 +57,8 @@ impl ModelBuilder {
}
}

fn by_str(path: &Path) -> CodeFile {
JavaConstruct::parse(ModelBuilder::read_content(path).as_str())
pub fn by_str(content: &str) -> CodeFile {
JavaConstruct::parse(content)
}

fn read_content(path: &Path) -> String {
Expand Down
19 changes: 18 additions & 1 deletion fkl_cli/src/generator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
///
#[cfg(test)]
mod tests {
use crate::deconstruct::model_builder::ModelBuilder;

#[test]
fn it_works() {

let code_file = ModelBuilder::by_str(r#"
@RestController
@Transactional
public class ApplicationController {
@PostMapping("/client/manager")
public ResponseEntity<AccountAccessResource> addAccountManager(@RequestBody final AddAccountManagerCommand command,
@ApiParam(hidden = true) final HttpMethod method, final WebRequest request) {
final AccountAccessResource result = new AccountAccessResource();
return new ResponseEntity<>(result, HttpStatus.CREATED);
}
}
"#);

println!("{:?}", code_file);
}
}

0 comments on commit 121bedc

Please sign in to comment.