First commit (wating to add alerts in budget)
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package com.axelor.apps.account.web;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.axelor.apps.account.db.CashInventory;
|
||||
import com.axelor.apps.base.service.ConvertNumberToFrenchWordsService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class CashInventoryControllerTest {
|
||||
|
||||
private CashInventoryController controller;
|
||||
private ActionRequest request;
|
||||
private ActionResponse response;
|
||||
private CashInventory cashInventory;
|
||||
private ConvertNumberToFrenchWordsService convertService;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
request = mock(ActionRequest.class);
|
||||
response = mock(ActionResponse.class);
|
||||
cashInventory = mock(CashInventory.class);
|
||||
convertService = mock(ConvertNumberToFrenchWordsService.class);
|
||||
|
||||
controller = new CashInventoryController(convertService); // ✅ No Guice needed
|
||||
|
||||
// Mock request.getContext().asType(CashInventory.class)
|
||||
com.axelor.rpc.Context context = mock(com.axelor.rpc.Context.class);
|
||||
when(request.getContext()).thenReturn(context);
|
||||
when(context.asType(CashInventory.class)).thenReturn(cashInventory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_withDecimalSolde() {
|
||||
// Given
|
||||
when(cashInventory.getTheoricalSolde()).thenReturn(new BigDecimal("1234.56"));
|
||||
when(convertService.convert(1234L)).thenReturn("mille deux cent trente-quatre");
|
||||
when(convertService.convert(56L)).thenReturn("cinquante-six");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_withIntegerSolde() {
|
||||
// Given
|
||||
when(cashInventory.getTheoricalSolde()).thenReturn(new BigDecimal("1000.00"));
|
||||
when(convertService.convert(1000L)).thenReturn("mille");
|
||||
when(convertService.convert(0L)).thenReturn("zéro");
|
||||
|
||||
|
||||
// Then
|
||||
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
|
||||
ArgumentCaptor<String> valueCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(response).setValue(keyCaptor.capture(), valueCaptor.capture());
|
||||
assertEquals("theoricalSoldeInWords", keyCaptor.getValue());
|
||||
assertEquals("mille dinars algériens et zéro Cts", valueCaptor.getValue());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testConvert_withNoDecimalPart() {
|
||||
// // Given
|
||||
// when(cashInventory.getTheoricalSolde()).thenReturn(new BigDecimal("42"));
|
||||
// when(convertService.convert(42L)).thenReturn("quarante-deux");
|
||||
// when(convertService.convert(0L)).thenReturn("zéro");
|
||||
|
||||
|
||||
// // Then
|
||||
// ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
|
||||
// ArgumentCaptor<String> valueCaptor = ArgumentCaptor.forClass(String.class);
|
||||
// verify(response).setValue(keyCaptor.capture(), valueCaptor.capture());
|
||||
// assertEquals("theoricalSoldeInWords", keyCaptor.getValue());
|
||||
// assertEquals("quarante-deux dinars algériens et zéro Cts",
|
||||
// valueCaptor.getValue());
|
||||
// }
|
||||
}
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
|
||||
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/axelor-test" />
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/bdd_sophal" />
|
||||
|
||||
<property name="javax.persistence.jdbc.user" value="axelor" />
|
||||
<property name="javax.persistence.jdbc.password" value="" />
|
||||
<property name="javax.persistence.jdbc.user" value="postgres" />
|
||||
<property name="javax.persistence.jdbc.password" value="root" />
|
||||
|
||||
<!--
|
||||
value="create" to build a new database on each run;
|
||||
|
||||
Reference in New Issue
Block a user