<commit_before>package com.laegler.microservice.model2code.generator

import com.laegler.microservice.adapter.model.Template
import com.laegler.microservice.adapter.model.World
import com.laegler.microservice.adapter.util.DefaultNamingStrategy
import com.laegler.microservice.adapter.util.FileUtil
import com.laegler.microservice.model.Architecture
import com.laegler.microservice.model.Artifact
import com.laegler.microservice.model.EndpointType
import com.laegler.microservice.model.Expose
import com.laegler.microservice.model2code.template.microservice.grpc.GrpcPomXml
import com.laegler.microservice.model2code.template.microservice.grpc.GrpcProjectGenerator
import com.laegler.microservice.model2code.template.microservice.grpc.client.gen.DefaultGrpcClientXtend
import com.laegler.microservice.model2code.template.microservice.grpc.model.res.GrpcProto
import org.junit.Ignore
import org.junit.runner.RunWith
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.mockito.junit.MockitoJUnitRunner
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import static org.mockito.ArgumentMatchers.*
import static org.mockito.Mockito.*

@RunWith(MockitoJUnitRunner.Silent)
class GrpcProjectGeneratorTest {

	protected static Logger log = LoggerFactory.getLogger(GrpcProjectGeneratorTest)

	@InjectMocks GrpcProjectGenerator unitUnderTest
	Architecture architecture
	Template template
	Template.Builder templateBuilder

	@Mock GrpcPomXml grpcPomXmlMock
	@Mock GrpcProto grpcProtoMock
	@Mock DefaultGrpcClientXtend defaultGrpcClientXtendMock
	@Mock World worldMock
	@Mock FileUtil fileHelperMock
	@Mock DefaultNamingStrategy namingStrategyMock

//	@Before
	def void setup() {
		MockitoAnnotations.initMocks(unitUnderTest);
		templateBuilder = Template.builder
		template = templateBuilder.build

		architecture = new Architecture => [
			name = 'test-project'
			artifacts = #[
				new Artifact => [
					name = 'product'
					exposes = #[
						new Expose => [
							name = 'ProductRest'
							endpointType = EndpointType.GRPC
						]
					]
				]
			]
		]
		
		when(namingStrategyMock.getProjectName(any())).thenCallRealMethod
		when(namingStrategyMock.srcPath).thenCallRealMethod
//		doReturn(templateBuilder.build).when(grpcPomXmlMock).getTemplate(any())
		
		// TODO:
		doReturn(templateBuilder.build).when(grpcPomXmlMock).getTemplate(any())
		doReturn(template).when(grpcProtoMock).getTemplate(any(), any())
		doReturn(template).when(defaultGrpcClientXtendMock).getTemplate(any())

		doReturn('product-grpc').when(namingStrategyMock).getProjectName('product', 'grpc')
	}

//	@Test
	@Ignore
	def void test_generate() {
		val projects = unitUnderTest.generate(architecture)

//		assertNotNull(projects)
//		assertEquals(1, projects.size)
	}

}<commit_msg>Update GrpcProjectGeneratorTest.xtend<commit_after>package com.laegler.microservice.model2code.generator

import com.laegler.microservice.adapter.model.Template
import com.laegler.microservice.adapter.model.World
import com.laegler.microservice.adapter.util.DefaultNamingStrategy
import com.laegler.microservice.adapter.util.FileUtil
import com.laegler.microservice.model.Architecture
import com.laegler.microservice.model.Artifact
import com.laegler.microservice.model.EndpointType
import com.laegler.microservice.model.Expose
import com.laegler.microservice.model2code.template.microservice.grpc.GrpcPomXml
import com.laegler.microservice.model2code.template.microservice.grpc.GrpcProjectGenerator
import com.laegler.microservice.model2code.template.microservice.grpc.client.gen.DefaultGrpcClientXtend
import com.laegler.microservice.model2code.template.microservice.grpc.model.res.GrpcProto
import org.junit.Ignore
import org.junit.runner.RunWith
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.mockito.junit.MockitoJUnitRunner
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import static org.mockito.ArgumentMatchers.*
import static org.mockito.Mockito.*

//@RunWith(MockitoJUnitRunner.Silent)
class GrpcProjectGeneratorTest {

	protected static Logger log = LoggerFactory.getLogger(GrpcProjectGeneratorTest)

	@InjectMocks GrpcProjectGenerator unitUnderTest
	Architecture architecture
	Template template
	Template.Builder templateBuilder

	@Mock GrpcPomXml grpcPomXmlMock
	@Mock GrpcProto grpcProtoMock
	@Mock DefaultGrpcClientXtend defaultGrpcClientXtendMock
	@Mock World worldMock
	@Mock FileUtil fileHelperMock
	@Mock DefaultNamingStrategy namingStrategyMock

	@Before
	def void setup() {
		MockitoAnnotations.initMocks(unitUnderTest);
		templateBuilder = Template.builder
		template = templateBuilder.build

		architecture = new Architecture => [
			name = 'test-project'
			artifacts = #[
				new Artifact => [
					name = 'product'
					exposes = #[
						new Expose => [
							name = 'ProductRest'
							endpointType = EndpointType.GRPC
						]
					]
				]
			]
		]
		
		when(namingStrategyMock.getProjectName(any())).thenCallRealMethod
		when(namingStrategyMock.srcPath).thenCallRealMethod
//		doReturn(templateBuilder.build).when(grpcPomXmlMock).getTemplate(any())
		
		// TODO:
		doReturn(templateBuilder.build).when(grpcPomXmlMock).getTemplate(any())
		doReturn(template).when(grpcProtoMock).getTemplate(any(), any())
		doReturn(template).when(defaultGrpcClientXtendMock).getTemplate(any())

		doReturn('product-grpc').when(namingStrategyMock).getProjectName('product', 'grpc')
	}

	@Test
	@Ignore
	def void test_generate() {
		val projects = unitUnderTest.generate(architecture)

//		assertNotNull(projects)
//		assertEquals(1, projects.size)
	}

}
{'fraction_non_alphanumeric': 0.09443656980864636, 'fraction_numerical': 0.002834868887313962, 'mean_word_length': 5.69632265717675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5331568', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1760, 'n_words': 261}