<commit_before>package lemon.shared.test.customer;

import static org.junit.Assert.*;

import java.util.List;
import java.util.UUID;

import lemon.shared.customer.Action;
import lemon.shared.customer.CustomMenu;
import lemon.shared.customer.CustomMenuLog;
import lemon.shared.customer.persistence.CustomMenuRepository;
import lemon.shared.service.ServiceType;
import lemon.shared.toolkit.idcenter.IdWorkerManager;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@RunWith(JUnit4.class)
public class CustomMenuRepositoryTest {
	private static final byte LEVEL = 9;
	private static final int CUST_ID = -5743;
	private ApplicationContext acx;
	private CustomMenuRepository customMenuMapper;

	@Before
	public void init() {
		String[] resource = { "classpath:spring-db.xml",
				"classpath:spring-dao.xml", "classpath:spring-service.xml" };
		acx = new ClassPathXmlApplicationContext(resource);
		customMenuMapper = acx.getBean(CustomMenuRepository.class);
		assertNotNull(customMenuMapper);
	}

	@Test
	public void add() {
		CustomMenu menu = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu));
	}

	@Test
	public void update() {
		CustomMenu menu = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu));
		String name = "NAME AFTER UPDATE";
		int sort = 300;
		byte menulevcod = 2;
		int supmenucode = 1;
		String type = "VIEW";
		menu.setName(name);
		menu.setSort(sort);
		menu.setMenulevcod(menulevcod);
		menu.setSupmenucode(supmenucode);
		menu.setType(type);
		assertNotEquals(0, customMenuMapper.editMenu(menu));
		
		menu = customMenuMapper.getMenu(menu.getMenu_id());
		assertEquals(name, menu.getName());
		assertEquals(sort, menu.getSort());
		assertEquals(menulevcod, menu.getMenulevcod());
		assertEquals(supmenucode, menu.getSupmenucode());
		assertEquals(type, menu.getType());
	}

	@Test
	public void batchDelete() {
		CustomMenu menu1 = getCustomMenu();
		CustomMenu menu2 = getCustomMenu();
		CustomMenu menu3 = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu1));
		assertNotEquals(0, customMenuMapper.addMenu(menu2));
		assertNotEquals(0, customMenuMapper.addMenu(menu3));
		
		int result = customMenuMapper.deleteMenu(new String[] {
				String.valueOf(menu1.getMenu_id()),
				String.valueOf(menu2.getMenu_id()),
				String.valueOf(menu3.getMenu_id()) });
		assertNotEquals(0, result);
		
		menu1 = customMenuMapper.getMenu(menu1.getMenu_id());
		assertNull(menu1);
		
		menu2 = customMenuMapper.getMenu(menu2.getMenu_id());
		assertNull(menu2);
		
		menu3 = customMenuMapper.getMenu(menu3.getMenu_id());
		assertNull(menu3);
	}
	
	@Test
	public void getMenuList(){
		assertNotEquals(0, customMenuMapper.deleteMenuByCustomer(CUST_ID));
		CustomMenu menu1 = getCustomMenu();
		CustomMenu menu2 = getCustomMenu();
		CustomMenu menu3 = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu1));
		assertNotEquals(0, customMenuMapper.addMenu(menu2));
		assertNotEquals(0, customMenuMapper.addMenu(menu3));
		
		List<CustomMenu> list = customMenuMapper.getMenuList(CUST_ID);
		assertNotNull(list);
		assertEquals(3, list.size());
	}
	
	@Test
	public void getMenuListByLevel(){
		assertNotEquals(0, customMenuMapper.deleteMenuByCustomer(CUST_ID));
		CustomMenu menu1 = getCustomMenu();
		CustomMenu menu2 = getCustomMenu();
		CustomMenu menu3 = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu1));
		assertNotEquals(0, customMenuMapper.addMenu(menu2));
		assertNotEquals(0, customMenuMapper.addMenu(menu3));
		
		List<CustomMenu> list = customMenuMapper.getMenuListByLevel(CUST_ID, LEVEL);
		assertNotNull(list);
		assertEquals(3, list.size());
	}
	
	@Test
	public void saveMenuSyncLog(){
		CustomMenuLog log = new CustomMenuLog();<commit_msg>fixed test issue.<commit_after>package lemon.shared.test.customer;

import static org.junit.Assert.*;

import java.util.List;
import java.util.UUID;

import lemon.shared.customer.Action;
import lemon.shared.customer.CustomMenu;
import lemon.shared.customer.CustomMenuLog;
import lemon.shared.customer.persistence.CustomMenuRepository;
import lemon.shared.service.ServiceType;
import lemon.shared.toolkit.idcenter.IdWorkerManager;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@RunWith(JUnit4.class)
public class CustomMenuRepositoryTest {
	private static final byte LEVEL = 9;
	private static final int CUST_ID = -5743;
	private ApplicationContext acx;
	private CustomMenuRepository customMenuMapper;

	@Before
	public void init() {
		String[] resource = { "classpath:spring-db.xml",
				"classpath:spring-dao.xml", "classpath:spring-service.xml" };
		acx = new ClassPathXmlApplicationContext(resource);
		customMenuMapper = acx.getBean(CustomMenuRepository.class);
		assertNotNull(customMenuMapper);
	}

	@Test
	public void add() {
		CustomMenu menu = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu));
	}

	@Test
	public void update() {
		CustomMenu menu = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu));
		String name = "<NAME> UPDATE";
		int sort = 300;
		byte menulevcod = 2;
		int supmenucode = 1;
		String type = "VIEW";
		menu.setName(name);
		menu.setSort(sort);
		menu.setMenulevcod(menulevcod);
		menu.setSupmenucode(supmenucode);
		menu.setType(type);
		assertNotEquals(0, customMenuMapper.editMenu(menu));
		
		menu = customMenuMapper.getMenu(menu.getMenu_id());
		assertEquals(name, menu.getName());
		assertEquals(sort, menu.getSort());
		assertEquals(menulevcod, menu.getMenulevcod());
		assertEquals(supmenucode, menu.getSupmenucode());
		assertEquals(type, menu.getType());
	}

	@Test
	public void batchDelete() {
		CustomMenu menu1 = getCustomMenu();
		CustomMenu menu2 = getCustomMenu();
		CustomMenu menu3 = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu1));
		assertNotEquals(0, customMenuMapper.addMenu(menu2));
		assertNotEquals(0, customMenuMapper.addMenu(menu3));
		
		int result = customMenuMapper.deleteMenu(new String[] {
				String.valueOf(menu1.getMenu_id()),
				String.valueOf(menu2.getMenu_id()),
				String.valueOf(menu3.getMenu_id()) });
		assertNotEquals(0, result);
		
		menu1 = customMenuMapper.getMenu(menu1.getMenu_id());
		assertNull(menu1);
		
		menu2 = customMenuMapper.getMenu(menu2.getMenu_id());
		assertNull(menu2);
		
		menu3 = customMenuMapper.getMenu(menu3.getMenu_id());
		assertNull(menu3);
	}
	
	@Test
	public void getMenuList(){
		assertNotEquals(0, customMenuMapper.deleteMenuByCustomer(CUST_ID));
		CustomMenu menu1 = getCustomMenu();
		CustomMenu menu2 = getCustomMenu();
		CustomMenu menu3 = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu1));
		assertNotEquals(0, customMenuMapper.addMenu(menu2));
		assertNotEquals(0, customMenuMapper.addMenu(menu3));
		
		List<CustomMenu> list = customMenuMapper.getMenuList(CUST_ID);
		assertNotNull(list);
		assertEquals(3, list.size());
	}
	
	@Test
	public void getMenuListByLevel(){
		customMenuMapper.deleteMenuByCustomer(CUST_ID);
		CustomMenu menu1 = getCustomMenu();
		CustomMenu menu2 = getCustomMenu();
		CustomMenu menu3 = getCustomMenu();
		assertNotEquals(0, customMenuMapper.addMenu(menu1));
		assertNotEquals(0, customMenuMapper.addMenu(menu2));
		assertNotEquals(0, customMenuMapper.addMenu(menu3));
		
		List<CustomMenu> list = customMenuMapper.getMenuListByLevel(CUST_ID, LEVEL);
		assertNotNull(list);
		assertEquals(3, list.size());
	}
	
	@Test
	public void saveMenuSyncLog(){
		CustomMenuLog log = new CustomMenuLog();
{'fraction_non_alphanumeric': 0.12038686688724866, 'fraction_numerical': 0.014889284805293968, 'mean_word_length': 5.967198581560283, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6723214', 'n_tokens_mistral': 2704, 'n_tokens_neox': 2496, 'n_words': 447}