Method: Blufin::YmlWriterBase#write_file_java
- Defined in:
- lib/core/yml_writers/yml_writer_base.rb
#write_file_java(path_and_file, contents, is_mock = false) ⇒ Object
Proxy method needed to handle mocks.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/core/yml_writers/yml_writer_base.rb', line 86 def write_file_java(path_and_file, contents, is_mock = false) all_paths = 'config|dao|dto|enums|field|filter|mapper|metadata|model|refiner|service|sort|validator' # This is the "mock interceptor" that writes all the auto-generated mocks. if is_mock package = path_and_file =~ /\/sdk/ ? 'sdk' : 'api' file = File.basename(path_and_file) type = path_and_file.split('/') type = type[type.length - 2] path = "#{Blufin::Config::get_path('Paths', 'BlufinJava')}/blufin-#{package}/src/test/java/org/blufin/mock/#{type}/" path_and_file = "#{path}#{file}" contents_intercepted = [] contents_intercepted = ['import lombok.EqualsAndHashCode;', '@EqualsAndHashCode(callSuper = false)'] if type == 'dto' contents.each do |line| if line =~ /^package\s+[A-Za-z0-9\.\-_].+(#{all_paths});/ contents_intercepted << line.gsub(/^package\s+[A-Za-z0-9.\-_].+./, "package org.blufin.mock.#{type};") elsif line =~ /^import\s+[A-Za-z0-9\.\-_].+(#{all_paths}).Mock([A-Z][A-Za-z]+)?;/ import_split = line.split('.') contents_intercepted << "import org.blufin.mock.#{import_split[import_split.length - 2]}.#{import_split[import_split.length - 1]}" else contents_intercepted << line end end contents = contents_intercepted end Blufin::Files::write_file_java(path_and_file, contents) end |