Skip to content

Commit

Permalink
增加sequence的cacheSize测试
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Jan 20, 2025
1 parent 060340a commit a7eca10
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/theory/thinking-in-functional-programming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 实用观点下的函数式编程思想

## 一. 什么是函数

## 二. 什么是Monad

## 三. 从函数到函子

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.nop.sys.dao.seq;

import io.nop.api.core.annotations.autotest.NopTestConfig;
import io.nop.autotest.junit.JunitBaseTestCase;
import io.nop.dao.DaoConstants;
import io.nop.dao.api.IDaoProvider;
import io.nop.sys.dao.entity.NopSysSequence;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.jupiter.api.Assertions.assertEquals;

@NopTestConfig(localDb = true, initDatabaseSchema = true)
public class TestSysSequenceGenerator extends JunitBaseTestCase {
static final Logger LOG = LoggerFactory.getLogger(TestSysSequenceGenerator.class);

@Inject
IDaoProvider daoProvider;

@Inject
SysSequenceGenerator generator;

@Test
public void testSequence() {
NopSysSequence seq = new NopSysSequence();
seq.setNextValue(100L);
seq.setSeqName("test");
seq.setCacheSize(200);
seq.setSeqType("default");
seq.setIsUuid(DaoConstants.NO_VALUE);
seq.setStepSize(1);

daoProvider.daoFor(NopSysSequence.class).saveEntity(seq);

String value = generator.generateString("test", true);
assertEquals("100", value);

LOG.info("before-generate");
value = generator.generateString("test", true);
assertEquals("101", value);

value = generator.generateString("test", true);
assertEquals("102", value);
LOG.info("after-generate");

NopSysSequence entity = daoProvider.daoFor(NopSysSequence.class).getEntityById(seq.orm_id());
assertEquals(300, entity.getNextValue());
}
}

0 comments on commit a7eca10

Please sign in to comment.