src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
ManageTagController { @PutMapping("/manage/tagList/enable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(@RequestParam String name) { tagRepository.getOne(name).setDisabled(false); } @GetMapping("/manageTag") String index(); @GetMapping("/manageTagAdd") String toAdd(); @GetMapping("/manage/...
@Test public void enable() throws Exception { changeDisable("/enable", false); }
ManageTagController { @GetMapping("/manageTagAdd") public String toAdd() { return "_tagOperator.html"; } @GetMapping("/manageTag") String index(); @GetMapping("/manageTagAdd") String toAdd(); @GetMapping("/manage/tagDetail") String detail(@RequestParam String name, Model model); @GetMapping("/manage/tagEdit") String e...
@Test public void check() throws Exception{ toAdd(); Tag tag = tagRepository.findAll().stream().max(new RandomComparator()).orElse(null); if (tag == null) { return; } MvcResult result = mockMvc.perform(get(TAG_LIST_URL + "/check") .param("name",tag.getName())) .andExpect(status().is2xxSuccessful()) .andReturn(); assert...
ManageCommonProblemController { @PreAuthorize("hasAnyRole('ROOT','" + Login.ROLE_PRODUCT_CENTER + "','" + Login.ROLE_LOOK + "')") @GetMapping("/manage/commonProblem") public String index() { return "operation-management/_helpCenter.html"; } @PreAuthorize("hasAnyRole('ROOT','" + Login.ROLE_PRODUCT_CENTER + "','" + Logi...
@Test public void index(){ Manager manager = newRandomManager(ManageLevel.root); updateAllRunWith(manager); String title = RandomStringUtils.randomAscii(10); commonProblemService.addAndEditCommonProblem(null, title,50 , RandomStringUtils.randomAscii(20)); driver.get("http: ManageHelpCenterPage manageHelpCenterPage = in...
ManageManagerController { @PreAuthorize("hasAnyRole('ROOT','" + Login.ROLE_GRANT + "')") @PostMapping("/manage/managers") @Transactional public String addUser(String name, String department, String realName, boolean enable, String comment , String[] role, @AuthenticationPrincipal Login login, RedirectAttributes redirec...
@Test public void pages() throws Exception { driver.get("http: System.out.println(driver.getPageSource()); addUser(); Login lastOne = loginRepository.findAll(new Sort(Sort.Direction.DESC, "id")).get(0); driver.get("http: System.out.println(driver.getPageSource()); assertThat(true) .isTrue(); } @Test public void addUser...
ManageManagerController { @GetMapping("/manage/managers") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition list(String name, String department, String realName) { return new RowDefinition<Manager>() { @Override public Class<Manager> entityClass() { return Manager.class; } @...
@Test public void list() throws Exception { addUser(); mockMvc.perform( get("/manage/managers") ) .andExpect(status().isOk()) .andDo(print()); assertThat(true) .isTrue(); }
ManageDepotController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageDepot") public String index() { return "_depotManage.html"; } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageDepot") String ...
@Test public void index() throws Exception { driver.get("http: assertThat(driver.getTitle()) .isEqualTo("仓库管理"); driver.get("http: assertThat(driver.getTitle()) .isEqualTo("新仓库"); }
ManageDepotController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manage/depotList") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition data() { return new DepotRows(time -> conversionService.convert(time, String.cl...
@Test public void data() throws Exception { add(); mockMvc.perform( get("/manage/depotList") ) .andExpect(status().isOk()) .andDo(print()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(similarJQueryDataTable("classpath:/manage-view/mock/depotList.json")); }
InitService { @PostConstruct @Transactional @Order(Ordered.HIGHEST_PRECEDENCE) public void init() throws IOException, SQLException { commons(); database(); upgrade(); managers(); productTypes(); depots(); products(); others(); mainOrderService.createExecutorToForPayOrder(); applicationEventPublisher.publishEvent(new In...
@Test public void init() throws Exception { Manager root = managerRepository.findByLoginName("root"); System.out.println(root); assertThat(root) .isNotNull(); }
ManageDepotController { @PostMapping("/manage/depotList") public String add(String name, Address address, String haierCode, String type, String chargePeopleName , String chargePeopleMobile) { Depot depot; if ("HaierDepot".equalsIgnoreCase(type)) { HaierDepot haierDepot = new HaierDepot(); haierDepot.setHaierCode(haierC...
@Test public void add() throws Exception { addNewHaierDepot(); addNewManuallyDepot(); }
ManageDepotController { @PutMapping("/manage/depotList/{id}/disable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void disable(@PathVariable("id") long id) { depotRepository.getOne(id).setEnable(false); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapp...
@Test public void disable() throws Exception { changeEnable("disable", false); }
ManageDepotController { @PutMapping("/manage/depotList/{id}/enable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(@PathVariable("id") long id) { depotRepository.getOne(id).setEnable(true); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping...
@Test public void enable() throws Exception { changeEnable("enable", true); }
ManageFactoryController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageFactory") public String index() { return "_factoryManage.html"; } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageFactory")...
@Test public void index() throws Exception { driver.get("http: assertThat(driver.getTitle()) .isEqualTo("工厂管理"); driver.get("http: assertThat(driver.getTitle()) .isEqualTo("新工厂"); }
ManageFactoryController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manage/factoryList") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition data() { return new RowDefinition<Factory>() { @Override public List<Order>...
@Test public void data() throws Exception { add(); mockMvc.perform( get("/manage/factoryList") ) .andExpect(status().isOk()) .andDo(print()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(similarJQueryDataTable("classpath:/manage-view/mock/factoryList.json")); }
ManageFactoryController { @PostMapping("/manage/factoryList") public String add(String name, Address address, String chargePeopleName , String chargePeopleMobile) { Factory factory = new Factory(); factory.setEnable(true); factory.setCreateTime(LocalDateTime.now()); factory.setName(name); factory.setAddress(address); f...
@Test public void add() throws Exception { addNewFactory(); }
ManageFactoryController { @PutMapping("/manage/factoryList/{id}/disable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void disable(@PathVariable("id") long id) { factoryRepository.getOne(id).setEnable(false); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @G...
@Test public void disable() throws Exception { changeEnable("disable", false); }
ManageFactoryController { @PutMapping("/manage/factoryList/{id}/enable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(@PathVariable("id") long id) { factoryRepository.getOne(id).setEnable(true); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetM...
@Test public void enable() throws Exception { changeEnable("enable", true); }
WechatMyController { private String myTeam(@AuthenticationPrincipal Login loginInput, Model model) { Login login = loginService.get(loginInput.getId()); if (loginService.isRegularLogin(login)) model.addAttribute("agentLevel", agentService.loginTitle(agentService.highestAgent(login))); else model.addAttribute("agentLeve...
@Test @Ignore public void myTeam() throws InterruptedException { Login master = newRandomAgent(); randomAgentTree(master); login = getSubAgents(master).stream() .max(new RandomComparator()).orElse(null).getLogin(); WechatMyPage myPage = getWechatMyPage(); Set<Login> agentLogin = agentLevelRepository.findAll().stream() ...
WechatShareController { @GetMapping(SystemService.wechatShareUri) public String share(@AuthenticationPrincipal Login loginInput, Model model) { Login login = loginService.get(loginInput.getId()); if (!loginService.isRegularLogin(login) && !loginService.allowShare(login)) return "redirect:" + SystemService.wechatShareMo...
@Test public void share() throws Exception { final Login newUser = createNewUserByShare(); System.out.println(newUser); }
MiscController { @RequestMapping(method = RequestMethod.POST, value = "/misc/sendRegisterCode") @ResponseBody public ApiResult sendRegisterCode(String mobile) throws IOException { if (loginService.byLoginName(mobile) != null) { return ApiResult.withCodeAndMessage(401, "该手机号码已被人使用", null); } verificationCodeService.send...
@Test public void sendRegisterCode() throws Exception { mockMvc.perform(post("/misc/sendRegisterCode") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param("mobile", randomMobile()) ) .andExpect(status().isOk()) .andExpect(jsonPath("$.resultCode").value(200)); final String mobile = randomMobile(); loginService.ne...
WechatController { @GetMapping("/toLoginWechat") public String login(WeixinUserDetail detail, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.trace(detail); Login login = loginService.asWechat(detail.getOpenId()); if (login == null) return "redirect:/wechatLogin"; if...
@Test public void bindWithPassword() throws Exception { WeixinUserDetail detail = nextCurrentWechatAccount(); LoginPage loginPage = getLoginPageForBrowseIndex(); String rawPassword = UUID.randomUUID().toString(); Login login = newRandomAgent(rawPassword); loginPage.login(login.getLoginName(), rawPassword + 1); loginPag...
WechatController { @GetMapping("/wechatForward/{goodId}_{id}") public String wechatForward(@OpenId String openId,@PathVariable Long goodId,@PathVariable Long id , HttpServletRequest request, HttpServletResponse response){ Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if(authent...
@Test public void wechatForwardTest(){ String rawPassword = UUID.randomUUID().toString(); Login login = newRandomAgent(rawPassword); MainGood mainGood = mainGoodService.forSale().stream().findAny().get(); String shareUrl = "http: LoginPage loginPage = getLoginPageForBrowseIndex(); loginPage.login(login.getLoginName(), ...
WechatCommonProblemController { @GetMapping(SystemService.helpCenterURi) public String index(){ return "wechat@helpCenter/index.html"; } @GetMapping("/commonProblemDetail/{id}") String commonProblemDetail(@PathVariable Long id, Model model); @GetMapping("/commonProblem/search") @ResponseBody Map<String, Object> search...
@Test public void index() throws Exception { String title = RandomStringUtils.randomAscii(10); commonProblemService.addAndEditCommonProblem(null, title,50 , RandomStringUtils.randomAscii(20)); driver.get("http: HelpCenterPage page = initPage(HelpCenterPage.class); page.assertHasTopic(title); HelpDetailPage helpDetailPa...
WechatUpgradeController { @PostMapping("/wechatUpgrade") @Transactional public ModelAndView upgrade(@AuthenticationPrincipal Login login, String agentName, int newLevel, Address address , String cardFrontPath , String cardBackPath, String businessLicensePath, String upgradeMode, HttpServletRequest servletRequest) throw...
@Test public void upgrade1() throws Exception { upgrade(1, 4); } @Test public void upgrade2() throws Exception { upgrade(2, 3); } @Test public void upgrade3() throws Exception { upgrade(3, 2); }
WelcomeController { @RequestMapping(method = RequestMethod.GET, value = {"", "/"}) public String index(@AuthenticationPrincipal Login login, @HighestAgent AgentLevel agentLevel) { if (login.isManageable()) return "redirect:/manage"; if (agentLevel != null) return "redirect:/agentMain"; throw new IllegalStateException("...
@Test public void index() throws Exception { String rawPassword = randomEmailAddress(); Manager manager = newRandomManager(rawPassword, ManageLevel.root); driver.get("http: WebLoginPage loginPage = initPage(WebLoginPage.class); loginPage.login(manager.getLoginName(), rawPassword); initPage(AgentManageMainPage.class); c...
CommissionController { public static String formatCommonInfo(Object origin) { String src = origin.toString(); int index = src.lastIndexOf("¥"); String first = src.substring(0, index - 1); return first + Money.format.format(new BigDecimal(src.substring(index + 1))); } static String formatCommonInfo(Object origin); @Row...
@Test public void formatCommonInfo() throws Exception { System.out.println(CommissionController.formatCommonInfo("1个厨下净水机 ¥2820.00000000000000000000")); NumberFormat format = NumberFormat.getPercentInstance(Locale.CHINA); format.setMaximumFractionDigits(2); System.out.println(format.format(BigDecimal.valueOf(0.05))); S...
AgentNavigateController { @RequestMapping(method = RequestMethod.GET, value = "/agentMain") public String agentMain(@AuthenticationPrincipal Login login, @HighestAgent AgentLevel agentLevel, Model model) { if (login.isManageable()) { model.addAttribute("title", "管理后台"); model.addAttribute("loginAs", login.getLoginTitle...
@Test public void agentMain() throws Exception { AgentManageMainPage mainPage = mainPage(); mainPage.selectMenu("fa-users"); mainPage.currentContext(AgentManagePage.class); mainPage = mainPage(); mainPage.selectMenu("fa-address-card-o"); AgentOrderManagePage agentOrderManagePage = mainPage.currentContext(AgentOrderMana...
LoginDataController { @PreAuthorize("!isAnonymous()") @GetMapping("/loginData/select2") @RowCustom(dramatizer = Select2Dramatizer.class, distinct = true) public RowDefinition<Login> searchLoginSelect2(String search, Boolean agent, Integer level) { return searchLogin(search, agent, level); } @GetMapping("/loginData/mob...
@Test public void searchLoginSelect2() throws Exception { int currentCount = JsonPath.read(mockMvc.perform( get("/loginData/select2") ) .andReturn().getResponse().getContentAsString(), "$.total_count"); final int count = random.nextInt(40) + 30; int i = count; String toSearch = ""; while (i-- > 0) { Login login = newRa...
AgentController { @GetMapping("/addAgent") @PreAuthorize("hasAnyRole('ROOT','" + Login.ROLE_AllAgent + "')") public String indexForAdd() { return "addAgent.html"; } @GetMapping("/agentManage") String index(@AuthenticationPrincipal Login login); @GetMapping("/agentDetail") String detail(long id, Model model); @GetMappi...
@Test public void indexForAdd() throws Exception { Manager manager = newRandomManager("", ManageLevel.customerManager); runWith(manager, () -> { mockMvc.perform(get("/addAgent")) .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andExpect(view().name("addAgent.html")); St...
OrderDataController { @RequestMapping(method = RequestMethod.GET, value = "/orderData/manageableList") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition manageableList(@AuthenticationPrincipal Login login, String orderId , @RequestParam(value = "phone", required = false) Str...
@Test public void manageableList() throws Exception { final Login order = testLogin; newRandomOrderFor(order, order); orderDataList(null); newRandomOrderFor(order, order); String serialId = mainOrderService.allOrders().stream() .filter(mainOrder -> mainOrder.getOrderBy().equals(order)) .max(Comparator.comparing(MainOrd...
ResourceController { @RequestMapping(method = RequestMethod.POST, value = "/webUploader") public ResponseEntity<?> webUploader(String id, MultipartFile file) throws IOException, URISyntaxException { try (InputStream inputStream = file.getInputStream()) { String path = uploadTempResource(inputStream, file); Resource res...
@Test public void webUploader() throws Exception { try (InputStream inputStream = randomPngImageResource().getInputStream()) { mockMvc.perform(fileUpload("/resourceUpload/webUploader") .file(new MockMultipartFile("file", "my_file.png", "image/png", inputStream)) ).andExpect( similarJsonObjectAs("classpath:/mock/webUplo...
ManageAgentController extends AbstractLoginDetailController { @PutMapping("/agent/superior/{id}") @PreAuthorize("hasAnyRole('ROOT')") @ResponseBody @Transactional public ApiResult changeSuperior(@RequestBody String newGuide, @PathVariable("id") long id) { final AgentLevel target = agentService.getAgent(id); if (!String...
@Test public void go() throws Exception { Login als[] = new Login[systemService.systemLevel()]; AgentLevel as[] = new AgentLevel[systemService.systemLevel()]; initAgentSystem(als, as); updateAllRunWith(newRandomManager(ManageLevel.root)); final AgentLevel toTestAgent = as[as.length - 2]; toTestAgent.getLogin().setGuide...
ManageTagController { @GetMapping("/manageTag") public String index() { return "_tagManage.html"; } @GetMapping("/manageTag") String index(); @GetMapping("/manageTagAdd") String toAdd(); @GetMapping("/manage/tagDetail") String detail(@RequestParam String name, Model model); @GetMapping("/manage/tagEdit") String edit(@...
@Test public void index() throws Exception { driver.get("http: assertThat(driver.getTitle()) .isEqualTo("标签管理"); driver.get("http: assertThat(driver.getTitle()) .isEqualTo("新增标签"); }
ManageTagController { @GetMapping("/manage/tagList") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition data() { return new TagRows(time -> conversionService.convert(time, String.class)) { @Override public Specification<Tag> specification() { return null; } }; } @GetMapping(...
@Test public void data() throws Exception { toAdd(); mockMvc.perform( get(TAG_LIST_URL) ) .andExpect(status().isOk()) .andDo(print()) .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(similarJQueryDataTable("classpath:/manage-view/mock/tagList.json")); }
DrillOptiq { public static LogicalExpression toDrill(DrillParseContext context, RelNode input, RexNode expr) { final RexToDrill visitor = new RexToDrill(context, input); return expr.accept(visitor); } static LogicalExpression toDrill(DrillParseContext context, RelNode input, RexNode expr); static boolean isLiteralNull...
@Test public void testUnsupportedRexNode() { try { RelDataTypeFactory relFactory = new SqlTypeFactoryImpl(DrillRelDataTypeSystem.DRILL_REL_DATATYPE_SYSTEM); RexBuilder rex = new RexBuilder(relFactory); RelDataType anyType = relFactory.createSqlType(SqlTypeName.ANY); List<RexNode> emptyList = new LinkedList<>(); Immutab...
MaterializedField { public MaterializedField clone() { return withPathAndType(getPath(), getType()); } private MaterializedField(SchemaPath path, MajorType type); private MaterializedField(SchemaPath path, MajorType type, LinkedHashSet<MaterializedField> children); static MaterializedField create(SerializedField serF...
@Test public void testClone() { final MaterializedField cloneParent = parent.clone(); final boolean isParentEqual = parent.equals(cloneParent); assertTrue("Cloned parent does not match the original", isParentEqual); final MaterializedField cloneChild = child.clone(); final boolean isChildEqual = child.equals(cloneChild...
Driver implements java.sql.Driver { @Override public int getMajorVersion() { return impl.getMajorVersion(); } Driver(); static boolean load(); @Override Connection connect( String url, Properties info ); @Override boolean acceptsURL( String url ); @Override DriverPropertyInfo[] getPropertyInfo( String url, Properties i...
@Test public void test_getMajorVersion() { assertThat( uut.getMajorVersion(), org.hamcrest.CoreMatchers.is( 0 ) ); }
Driver implements java.sql.Driver { @Override public int getMinorVersion() { return impl.getMinorVersion(); } Driver(); static boolean load(); @Override Connection connect( String url, Properties info ); @Override boolean acceptsURL( String url ); @Override DriverPropertyInfo[] getPropertyInfo( String url, Properties i...
@Test public void test_getMinorVersion() { assertThat( uut.getMinorVersion(), org.hamcrest.core.Is.is( 0 ) ); }
TypeConvertingSqlAccessor implements SqlAccessor { @Override public byte getByte( int rowOffset ) throws InvalidAccessException { final byte result; switch ( getType().getMinorType() ) { case TINYINT: result = innerAccessor.getByte( rowOffset ); break; case SMALLINT: result = getByteValueOrThrow( innerAccessor.getShort...
@Test public void test_getByte_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getByte( 0 ), equalTo( (byte) 127 ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (by...
TypeConvertingSqlAccessor implements SqlAccessor { @Override public short getShort( int rowOffset ) throws InvalidAccessException { final short result; switch ( getType().getMinorType() ) { case SMALLINT: result = innerAccessor.getShort( rowOffset ); break; case TINYINT: result = innerAccessor.getByte( rowOffset ); bre...
@Test public void test_getShort_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getShort( 0 ), equalTo( (short) 127 ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( ...
TypeConvertingSqlAccessor implements SqlAccessor { @Override public int getInt( int rowOffset ) throws InvalidAccessException { final int result; switch ( getType().getMinorType() ) { case INT: result = innerAccessor.getInt( rowOffset ); break; case TINYINT: result = innerAccessor.getByte( rowOffset ); break; case SMAL...
@Test public void test_getInt_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getInt( 0 ), equalTo( 127 ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) -128 ...
TypeConvertingSqlAccessor implements SqlAccessor { @Override public long getLong( int rowOffset ) throws InvalidAccessException { final long result; switch ( getType().getMinorType() ) { case BIGINT: result = innerAccessor.getLong( rowOffset ); break; case TINYINT: result = innerAccessor.getByte( rowOffset ); break; ca...
@Test public void test_getLong_on_TINYINT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) 127 ) ); assertThat( uut1.getLong( 0 ), equalTo( 127L ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new TinyIntStubAccessor( (byte) -1...
TypeConvertingSqlAccessor implements SqlAccessor { @Override public float getFloat( int rowOffset ) throws InvalidAccessException { final float result; switch ( getType().getMinorType() ) { case FLOAT4: result = innerAccessor.getFloat( rowOffset ); break; case INT: result = innerAccessor.getInt( rowOffset ); break; cas...
@Test public void test_getFloat_on_FLOAT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new FloatStubAccessor( 1.23f ) ); assertThat( uut1.getFloat( 0 ), equalTo( 1.23f ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new FloatStubAccessor( Float.MAX_VALUE )...
TypeConvertingSqlAccessor implements SqlAccessor { @Override public double getDouble( int rowOffset ) throws InvalidAccessException { final double result; switch ( getType().getMinorType() ) { case FLOAT8: result = innerAccessor.getDouble( rowOffset ); break; case INT: result = innerAccessor.getInt( rowOffset ); break;...
@Test public void test_getDouble_on_FLOAT_getsIt() throws InvalidAccessException { final SqlAccessor uut1 = new TypeConvertingSqlAccessor( new FloatStubAccessor( 6.02e23f ) ); assertThat( uut1.getDouble( 0 ), equalTo( (double) 6.02e23f ) ); final SqlAccessor uut2 = new TypeConvertingSqlAccessor( new FloatStubAccessor( ...
ModelExtractor { public byte[] getModel(String modelUri) { return getModel(new DefaultResourceLoader().getResource(modelUri)); } ModelExtractor(); ModelExtractor(String frozenGraphFileExtension); byte[] getModel(String modelUri); byte[] getModel(Resource modelResource); final String frozenGraphFileExtension; }
@Test public void testResourceAndStringArguments() { Resource modelResource = new DefaultResourceLoader().getResource("classpath:/tensorflow/model/linear_regression_graph.proto"); byte[] model1 = new ModelExtractor().getModel(modelResource); assertThat(model1.length, is(422)); byte[] model2 = new ModelExtractor().getMo...
PropertyUtils { public static <T> T get(String key, Function<String, T> parser, T defaultValue) { return get(System.getProperties(), key, parser, defaultValue); } private PropertyUtils(); static T get(String key, Function<String, T> parser, T defaultValue); static T get(Properties props, String key, Function<String, T...
@Test public void testSystemGet() { assertEquals("bar", PropertyUtils.get("_foo", String::valueOf, "bar")); } @Test public void testExistingValue() { final Properties props = new Properties(); props.put("foo", "bar"); assertEquals("bar", PropertyUtils.get(props, "foo", String::valueOf, "baz")); } @Test public void test...
PropertyUtils { public static Properties filter(String keyPrefix, Properties props) { final Properties filtered = new Properties(); final Enumeration<?> keys = props.propertyNames(); while (keys.hasMoreElements()) { final String key = (String) keys.nextElement(); final String value = props.getProperty(key); if (value !...
@Test public void testFilterWithDefaults() { final Properties props = new Properties(); props.put("a.foo", "foo"); props.put("a.bar", "bar"); props.put("b.foo", "bar"); final Properties filtered = PropertyUtils.filter("a.", new Properties(props)); assertEquals(2, filtered.size()); assertTrue(filtered.containsKey("a.foo...
StochasticOscillator implements Indicator { private static <T> void add(List<T> list, T value, int cap) { list.add(value); while (list.size() > cap) list.remove(0); } StochasticOscillator(int lookback, int kPeriod); @Override StochasticOutput add(Bar bar); }
@Test public void test() { final StochasticOscillator fast = new StochasticOscillator(14, 3); assertNull(fast.add(bar(127.0090f, 125.3574f, 127.0090f))); assertNull(fast.add(bar(127.6159f, 126.1633f, 127.6159f))); assertNull(fast.add(bar(126.5911f, 124.9296f, 126.5911f))); assertNull(fast.add(bar(127.3472f, 126.0937f, ...
PropertyUtils { public static <T> T getOrSet(Properties props, String key, Function<String, T> parser, T defaultValue) { final String str = props.getProperty(key); if (str == null) { props.setProperty(key, String.valueOf(defaultValue)); return defaultValue; } else { return parser.apply(str); } } private PropertyUtils(...
@Test public void testGetOrSetExisting() { final Properties props = new Properties(); props.put("foo", "bar"); assertEquals("bar", PropertyUtils.getOrSet(props, "foo", String::valueOf, "baz")); assertEquals("bar", props.getProperty("foo")); } @Test public void testGetOrSetDefault() { final Properties props = new Proper...
PropertyUtils { public static Properties load(String resourceFile) throws IOException { final URL url = PropertyUtils.class.getClassLoader().getResource(resourceFile); if (url == null) throw new FileNotFoundException("Resource not found"); final Properties props = new Properties(); try (InputStream in = url.openStream(...
@Test public void testLoadExisting() throws IOException { final Properties props = PropertyUtils.load("property-utils-test.properties"); assertTrue(props.containsKey("foo")); } @Test public void testLoadExistingDefault() throws IOException { final Properties props = PropertyUtils.load("property-utils-test.properties", ...
MidaoFactory { public static QueryRunnerService getQueryRunner(DataSource ds) { return (QueryRunnerService) ProfilerFactory.newInstance(new QueryRunner(ds)); } static QueryRunnerService getQueryRunner(DataSource ds); static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz)...
@Test public void testGetQueryRunnerDataSource() throws Exception { Assert.assertEquals(true, MidaoFactory.getQueryRunner(ds) instanceof QueryRunner); } @Test public void testGetQueryRunnerDataSourceTypeHandler() throws Exception { Assert.assertEquals(true, MidaoFactory.getQueryRunner(ds, EmptyTypeHandler.class) instan...
QueryParameters { public Object getValueByPosition(Integer position) throws NoSuchFieldException { String name = null; Object value = null; name = this.getNameByPosition(position); if (name != null) { value = this.getValue(name); } else { throw new NoSuchFieldException(); } return value; } QueryParameters(); QueryPara...
@Test public void testConstructorArray() throws NoSuchFieldException { QueryParameters params = new QueryParameters(superman.getName(), superman.getOrigin(), superman.getStrength()); Assert.assertEquals(superman.getName(), params.getValueByPosition(0)); Assert.assertEquals(superman.getOrigin(), params.getValueByPositio...
QueryParameters { public void importValues(Map<String, Object> map) { for (String key : map.keySet()) { this.set(key, map.get(key)); } } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedIn...
@Test public void testImportValues() throws Exception { QueryParameters params = new QueryParameters(); params.importValues(superMap); Assert.assertEquals(superMap.get("name"), params.getValue("name")); Assert.assertEquals(superMap.get("origin"), params.getValue("origin")); Assert.assertEquals(superMap.get("strength"),...
QueryParameters { public QueryParameters setClassName(String className) { InputUtils.setClassName(this.values, className); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedI...
@Test public void testSetClassName() throws Exception { String className = "Superman"; QueryParameters params = new QueryParameters(superman); params.setClassName(className); Assert.assertEquals(className, InputUtils.getClassName(params.toMap())); }
QueryParameters { public QueryParameters updateType(String key, Integer type) { this.types.put(processKey(key), type); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput...
@Test public void testUpdateType() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(MjdbcTypes.OTHER, params.getType("name").intValue()); params.updateType("name", 2); Assert.assertEquals(2, params.getType("name").intValue()); }
QueryParameters { public QueryParameters updateDirection(String key, Direction direction) { this.direction.put(processKey(key), direction); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryPara...
@Test public void testUpdateDirection() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(QueryParameters.Direction.IN, params.getDirection("name")); params.updateDirection("name", QueryParameters.Direction.INOUT); Assert.assertEquals(QueryParameters.Dir...
QueryParameters { public QueryParameters updatePosition(String key, Integer position) { while (this.order.size() < position + 1) { this.order.add(null); } this.order.set(position, processKey(key)); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean)...
@Test public void testUpdatePosition() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); if (JAVA_VERSION == 1.8) { Assert.assertEquals(2, params.getFirstPosition("name").intValue()); } else { Assert.assertEquals(1, params.getFirstPosition("name").intValue()); } params.upda...
QueryParameters { public QueryParameters updateValue(String key, Object value) { this.values.put(processKey(key), value); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedIn...
@Test public void testUpdateValue() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(superman.getName(), params.getValue("name")); params.updateValue("name", "batman"); Assert.assertEquals("batman", params.getValue("name")); }
QueryParameters { public Integer getFirstPosition(String key) { int position = -1; String processedKey = processKey(key); if (this.values.containsKey(processedKey) == true) { position = this.order.indexOf(processedKey); } return position; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(...
@Test public void testGetPosition() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); if (JAVA_VERSION == 1.8) { Assert.assertEquals(2, params.getFirstPosition("name").intValue()); } else { Assert.assertEquals(1, params.getFirstPosition("name").intValue()); } }
QueryParameters { public Direction getDirection(String key) { return this.direction.get(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryPa...
@Test public void testGetDirection() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(QueryParameters.Direction.IN, params.getDirection("name")); }
QueryParameters { public Integer getType(String key) { return this.types.get(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(Ob...
@Test public void testGetType() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(MjdbcTypes.OTHER, params.getType("name").intValue()); }
MidaoFactory { public static DataSource createDataSource(Properties poolProperties) throws SQLException { try { return MidaoFrameworkPoolBinder.createDataSource(poolProperties); } catch (NoClassDefFoundError ex) { throw new NoClassDefFoundError(ERROR_COULDNT_FIND_POOL_PROVIDER); } } static QueryRunnerService getQueryR...
@Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceUrl3() throws Exception { MidaoFactory.createDataSource("", "", "", ""); } @Test(expected = NoClassDefFoundError.class) public void testCreateDataSourceUrl4() throws Exception { MidaoFactory.createDataSource("", "", "", "", 0, 0); } @Test(expe...
QueryParameters { public Object getValue(String key) { return this.values.get(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(O...
@Test public void testGetValue() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(superman.getName(), params.getValue("name")); } @Test public void testConstructorMap() { QueryParameters params = new QueryParameters(superMap); Assert.assertEquals(superM...
QueryParameters { public Map<String, Object> toMap() { return new HashMap<String, Object>(this.values); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryPara...
@Test public void testToMap() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Map<String, Object> map = params.toMap(); Assert.assertEquals(superman.getName(), map.get("name")); Assert.assertEquals(superman.getOrigin(), map.get("origin")); Assert.assertEquals(superman.get...
QueryParameters { public Set<String> keySet() { return this.values.keySet(); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(Object... params); v...
@Test public void testKeySet() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertTrue(Arrays.asList(new Object[]{"strength", "name", "origin"}).containsAll(params.keySet())); }
QueryParameters { public boolean isOutParameter(String key) { boolean isOut = false; if (this.getDirection(processKey(key)) == Direction.INOUT || this.getDirection(processKey(key)) == Direction.OUT) { isOut = true; } return isOut; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?>...
@Test public void testIsOutParameter() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(false, params.isOutParameter("name")); params.updateDirection("name", QueryParameters.Direction.INOUT); Assert.assertEquals(true, params.isOutParameter("name")); par...
QueryParameters { public boolean isInParameter(String key) { boolean isIn = false; if (this.getDirection(processKey(key)) == Direction.INOUT || this.getDirection(processKey(key)) == Direction.IN) { isIn = true; } return isIn; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> claz...
@Test public void testIsInParameter() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(true, params.isInParameter("name")); params.updateDirection("name", QueryParameters.Direction.INOUT); Assert.assertEquals(true, params.isInParameter("name")); params....
QueryParameters { public String getNameByPosition(Integer position) { String name = null; name = this.order.get(position); return name; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedI...
@Test public void testGetNameByPosition() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); if (JAVA_VERSION == 1.8) { Assert.assertEquals("name", params.getNameByPosition(2)); } else { Assert.assertEquals("name", params.getNameByPosition(1)); } }
QueryParameters { public boolean containsKey(String key) { return this.values.containsKey(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); Query...
@Test public void testContainsKey() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(true, params.containsKey("name")); Assert.assertEquals(true, params.containsKey("origin")); Assert.assertEquals(true, params.containsKey("strength")); }
QueryParameters { public void remove(String key) { String processedKey = processKey(key); String orderKey = null; for (int i = 0; i < this.order.size(); i++) { orderKey = this.order.get(i); if (orderKey != null && orderKey.equals(processedKey) == true) { this.order.remove(i); } } this.types.remove(processedKey); this.d...
@Test public void testRemove() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(true, params.containsKey("name")); Assert.assertEquals(true, params.containsKey("strength")); Assert.assertEquals(true, params.containsKey("origin")); params.remove("name");...
QueryParameters { public int size() { return this.values.size(); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(Object... params); void importVa...
@Test public void testSize() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(3, params.size()); params.remove("name"); Assert.assertEquals(2, params.size()); }
QueryParameters { public void setCaseSensitive(boolean newValue) { this.isCaseSensitive = newValue; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParamete...
@Test public void testSetCaseSensitive() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); params.setCaseSensitive(false); Assert.assertEquals(3, params.size()); params.set("NaMe", "batman"); Assert.assertEquals(3, params.size()); params.setCaseSensitive(true); params.set("...
QueryParameters { public boolean isCaseSensitive() { return this.isCaseSensitive; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(Object... param...
@Test public void testIsCaseSensitive() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(false, params.isCaseSensitive()); }
QueryParameters { public void setReturn(Object queryOutput) { this.set(QUERY_PARAMS_RETURN, queryOutput); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryPa...
@Test public void testSetReturn() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); List<QueryParameters> paramsList = new ArrayList<QueryParameters>(); params.setReturn(paramsList); Assert.assertEquals(paramsList, params.getReturn()); }
QueryParameters { public Object getReturn() { Object result = null; if (this.containsKey(QUERY_PARAMS_RETURN) == true) { result = this.getValue(QUERY_PARAMS_RETURN); } return result; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryPara...
@Test public void testGetReturn() throws Exception { testSetReturn(); }
QueryParameters { public void removeReturn() { if (this.containsKey(QUERY_PARAMS_RETURN) == true) { this.remove(QUERY_PARAMS_RETURN); } } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedI...
@Test public void testRemoveReturn() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); List<QueryParameters> paramsList = new ArrayList<QueryParameters>(); params.setReturn(paramsList); Assert.assertEquals(paramsList, params.getReturn()); params.removeReturn(); Assert.asser...
QueryParameters { public void update(Object[] newValues, boolean updateOutOnly) { AssertUtils.assertNotNull(newValues); if (newValues.length != this.values.size()) { throw new IllegalArgumentException(ERROR_INCORRECT_LENGTH); } this.assertIncorrectOrder(); String parameterName = null; for (int i = 0; i < newValues.leng...
@Test public void testUpdate() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Object[] expectedValues = new Object[]{superman.getName(), superman.getOrigin(), superman.getStrength()}; Object[] updateValues = new Object[]{null, "batman", "earth"}; Object[] updatedValues =...
QueryParameters { public void updateAndClean(ProcessedInput processedInput) { List<String> processedParameters = new ArrayList<String>(); if (processedInput.getAmountOfParameters() > 0) { String parameterName = null; for (int i = 0; i < processedInput.getAmountOfParameters(); i++) { parameterName = processedInput.getPa...
@Test public void testUpdateAndClean() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); params.set("once_bested_by", "doomsday"); Object[] updatedValues = new Object[]{100, "batman", "earth"}; ProcessedInput processedInput = new ProcessedInput("original query"); processedI...
QueryParameters { public Object[] getValuesArray() { this.assertIncorrectOrder(); Object[] params = new Object[this.order.size()]; String parameterName = null; for (int i = 0; i < this.order.size(); i++) { parameterName = this.getNameByPosition(i); params[i] = this.getValue(parameterName); } return params; } QueryParam...
@Test public void testGetValuesArray() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertTrue(Arrays.asList(new Object[]{superman.getStrength(), superman.getName(), superman.getOrigin()}).containsAll(Arrays.asList(params.getValuesArray()))); }
QueryParameters { public boolean isOrderSet() { boolean result = true; if (this.values.size() != this.order.size()) { result = false; } return result; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParame...
@Test public void testIsOrderSet() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); Assert.assertEquals(true, params.isOrderSet()); params.remove("strength"); params.updateValue("strength", 99); Assert.assertEquals(false, params.isOrderSet()); }
QueryParameters { public void assertIncorrectOrder() { if (this.isOrderSet() == false) { throw new IllegalArgumentException(ERROR_ORDER_NOT_INIT); } } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParamete...
@Test public void testAssertIncorrectOrder() throws Exception { QueryParameters params = new QueryParameters(superman.getClass(), superman); try { params.assertIncorrectOrder(); } catch (IllegalArgumentException ex) { fail(); } params.remove("strength"); params.updateValue("strength", 99); try { params.assertIncorrectO...
BaseExceptionHandler implements ExceptionHandler { public BaseExceptionHandler(String dbName) { this.dbName = dbName; } BaseExceptionHandler(String dbName); MjdbcSQLException convert(Connection conn, SQLException cause, String sql, Object... params); }
@Test public void testBaseExceptionHandler() throws SQLException { ((QueryRunner) runner).setExceptionHandler(baseExceptionHandler); try { runner.query("SQL generates Exception", new MapOutputHandler()); } catch (Exception ex) { Assert.assertEquals(" Query: SQL generates Exception Parameters: [QueryParameters CI { }]",...
ProcessedInput { public void addParameter(String parameterName, int parameterStart, int parameterEnd, String parameterType, String parameterDirection) { if (this.sqlParameterNames == null) { this.sqlParameterNames = new ArrayList<String>(); this.sqlParameterBoundaries = new ArrayList<int[]>(); } this.sqlParameterNames....
@Test public void testAddParameter() throws Exception { ProcessedInput processedInput = new ProcessedInput("original SQL"); processedInput.addParameter("parameter", 3, 9); Assert.assertEquals("parameter", processedInput.getSqlParameterNames().get(0)); org.junit.Assert.assertArrayEquals(new int[]{3, 9}, processedInput.g...
ProcessedInput { public String getOriginalSql() { return originalSql; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParameterValues, List<Stri...
@Test public void testGetOriginalSql() throws Exception { String originalSql = "original SQL"; ProcessedInput processedInput = new ProcessedInput(originalSql); Assert.assertEquals(originalSql, processedInput.getOriginalSql()); }
ProcessedInput { public String getParsedSql() { return parsedSql; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParameterValues, List<String> ...
@Test public void testGetParsedSql() throws Exception { String originalSql = "original SQL"; String parsedSql = "parsed SQL"; ProcessedInput processedInput = new ProcessedInput(originalSql); processedInput.setParsedSql(parsedSql); Assert.assertEquals(originalSql, processedInput.getOriginalSql()); Assert.assertEquals(pa...
ProcessedInput { public List<String> getSqlParameterNames() { return sqlParameterNames; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParamete...
@Test public void testGetSqlParameterNames() throws Exception { List<String> sqlParameterNames = new ArrayList<String>(); sqlParameterNames.add("name"); sqlParameterNames.add("origin"); sqlParameterNames.add("strength"); ProcessedInput processedInput = new ProcessedInput(""); processedInput.addParameter(sqlParameterNam...
ProcessedInput { public List<int[]> getSqlParameterBoundaries() { return sqlParameterBoundaries; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sq...
@Test public void testGetSqlParameterBoundaries() throws Exception { List<int[]> sqlParameterBoundaries = new ArrayList<int[]>(); sqlParameterBoundaries.add(new int[]{1, 2}); sqlParameterBoundaries.add(new int[]{3, 4}); sqlParameterBoundaries.add(new int[]{5, 6}); ProcessedInput processedInput = new ProcessedInput("");...
ProcessedInput { public List<Object> getSqlParameterValues() { return sqlParameterValues; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParame...
@Test public void testGetSqlParameterValues() throws Exception { List<Object> sqlParameterValues = new ArrayList<Object>(); sqlParameterValues.add("1"); sqlParameterValues.add("2"); sqlParameterValues.add("3"); ProcessedInput processedInput = new ProcessedInput(""); processedInput.setSqlParameterValues(sqlParameterValu...
ProcessedInput { public void setParsedSql(String parsedSql) { this.parsedSql = parsedSql; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParame...
@Test public void testSetParsedSql() throws Exception { testGetParsedSql(); }
ProcessedInput { public void setSqlParameterValues(List<Object> sqlParameterValues) { if (sqlParameterValues != null) { this.sqlParameterValues = new ArrayList<Object>(sqlParameterValues); } else { this.sqlParameterValues = null; } } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); P...
@Test public void testSetSqlParameterValues() throws Exception { testGetSqlParameterValues(); }
ProcessedInput { public Integer getPosition(String parameterName) { Integer position = null; for (int i = 0; i < this.sqlParameterNames.size(); i++) { if (this.sqlParameterNames.get(i).equals(parameterName) == true) { position = i; break; } } return position; } ProcessedInput(String originalSql); ProcessedInput(Proces...
@Test public void testGetPosition() throws Exception { ProcessedInput processedInput = new ProcessedInput(""); processedInput.addParameter("name", 1, 2); processedInput.addParameter("origin", 3, 4); processedInput.addParameter("strength", 5, 6); Assert.assertEquals(0, processedInput.getPosition("name").intValue()); Ass...
ProcessedInput { public String getParameterName(Integer position) { String name = null; if (this.sqlParameterNames != null) { name = this.sqlParameterNames.get(position); } return name; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parse...
@Test public void testGetParameterName() throws Exception { ProcessedInput processedInput = new ProcessedInput(""); processedInput.addParameter("name", 1, 2); processedInput.addParameter("origin", 3, 4); processedInput.addParameter("strength", 5, 6); Assert.assertEquals("name", processedInput.getParameterName(0)); Asse...
ExceptionUtils { public static void rethrow(MjdbcException cause) throws MjdbcSQLException { MjdbcSQLException ex = new MjdbcSQLException(cause.getMessage()); ex.setStackTrace(cause.getStackTrace()); throw ex; } static void rethrow(MjdbcException cause); }
@Test public void testRethrow() { try { ExceptionUtils.rethrow(new MjdbcException()); fail(); } catch (MjdbcSQLException ex) { } }
ProcessedInput { public Integer getAmountOfParameters() { Integer size = 0; if (this.sqlParameterNames != null) { size = this.sqlParameterNames.size(); } return size; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> ...
@Test public void testGetAmountOfParameters() throws Exception { ProcessedInput processedInput = new ProcessedInput(""); Assert.assertEquals(0, processedInput.getAmountOfParameters().intValue()); processedInput.addParameter("name", 1, 2); processedInput.addParameter("origin", 3, 4); processedInput.addParameter("strengt...
ProcessedInput { public boolean isFilled() { boolean isFilled = false; if (this.originalSql != null && this.originalSql.length() > 0) { if (this.parsedSql != null && this.parsedSql.length() > 0) { if (this.sqlParameterNames != null) { if (this.sqlParameterValues != null) { isFilled = true; } } } } return isFilled; } Pr...
@Test public void testIsFilled() throws Exception { ProcessedInput processedInput = new ProcessedInput("a"); processedInput.addParameter("name", 1, 2); processedInput.addParameter("origin", 3, 4); processedInput.addParameter("strength", 5, 6); Assert.assertEquals(false, processedInput.isFilled()); processedInput.setPar...
ProcessedInput { public void fillParameterValues(Map<String, Object> valuesMap) { AssertUtils.assertNotNull(valuesMap, "Value map cannot be null"); if (this.sqlParameterNames != null) { String parameterName = null; this.sqlParameterValues = new ArrayList<Object>(); for (int i = 0; i < this.sqlParameterNames.size(); i++...
@Test public void testFillParameterValues() throws Exception { ProcessedInput processedInput = new ProcessedInput("a"); processedInput.addParameter("name", 1, 2); processedInput.addParameter("origin", 3, 4); processedInput.addParameter("strength", 5, 6); org.junit.Assert.assertArrayEquals(new Object[0], processedInput....
EmptyTypeHandler implements TypeHandler { public QueryParameters processInput(Statement stmt, QueryParameters params) { return params; } EmptyTypeHandler(Overrider overrider); QueryParameters processInput(Statement stmt, QueryParameters params); void afterExecute(Statement stmt, QueryParameters processedInput, QueryPar...
@Test public void testProcessInput() throws Exception { new EmptyTypeHandler(new Overrider()).processInput(stmt, params); MappingUtils.invokeFunction(verify(conn, never()), "createBlob", new Class[]{}, new Object[]{}); MappingUtils.invokeFunction(verify(conn, never()), "createClob", new Class[]{}, new Object[]{}); Mapp...
EmptyTypeHandler implements TypeHandler { public void afterExecute(Statement stmt, QueryParameters processedInput, QueryParameters params) { } EmptyTypeHandler(Overrider overrider); QueryParameters processInput(Statement stmt, QueryParameters params); void afterExecute(Statement stmt, QueryParameters processedInput, Qu...
@Test public void testAfterExecute() throws Exception { QueryParameters processedParams = new QueryParameters(params); processedParams.set("array_list", processedParams.getValue("array")); processedParams.set("blob_byte", processedParams.getValue("blob")); processedParams.set("clob_byte", processedParams.getValue("clob...
EmptyTypeHandler implements TypeHandler { public List<QueryParameters> processOutput(Statement stmt, List<QueryParameters> paramsList) { return paramsList; } EmptyTypeHandler(Overrider overrider); QueryParameters processInput(Statement stmt, QueryParameters params); void afterExecute(Statement stmt, QueryParameters pro...
@Test public void testProcessOutput() throws Exception { new EmptyTypeHandler(new Overrider()).processOutput(stmt, params); verify(array, never()).getArray(); verify(blob, never()).getBinaryStream(); verify(clob, never()).getAsciiStream(); MappingUtils.invokeFunction(verify(sqlXml, never()), "getBinaryStream", new Clas...
TypeHandlerUtils { public static Object convertArray(Connection conn, Object[] array) throws SQLException { Object result = null; result = createArrayOf(conn, convertJavaClassToSqlType(array.getClass().getComponentType().getSimpleName()), array); return result; } static Object convertArray(Connection conn, Object[] ar...
@Test public void testConvertArrayArray() throws Exception { Object[] array = new String[]{"Sun"}; TypeHandlerUtils.convertArray(conn, array); MappingUtils.invokeFunction(verify(conn, times(1)), "createArrayOf", new Class[]{String.class, Object[].class}, new Object[]{"VARCHAR", array}); } @Test public void testConvertA...
TypeHandlerUtils { public static Object convertBlob(Connection conn, byte[] value) throws SQLException { Object result = createBlob(conn); result = convertBlob(result, value); return result; } static Object convertArray(Connection conn, Object[] array); static Object convertArray(Connection conn, Collection<?> array);...
@Test public void testConvertBlobConnByte() throws Exception { testConvertBlobPrepare(); TypeHandlerUtils.convertBlob(conn, "GIF".getBytes()); MappingUtils.invokeFunction(verify(conn, times(1)), "createBlob", new Class[]{}, new Object[]{}); testConvertBlobCheck(); } @Test public void testConvertBlobConnInputStream() th...