Skip to content

Commit

Permalink
修复单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Jan 3, 2024
1 parent 42ef296 commit f78bc30
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static int murmur3_32(String str) {
}

public static IHash64Function<String> murmur3_64_string() {
HashFunction h = Hashing.murmur3_32();
HashFunction h = Hashing.murmur3_128();
return str -> {
return h.hashString(str, StringHelper.CHARSET_UTF8).asLong();
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1:[0]44563 |[1]333 |[2]ABCDEFG...
2:[0]44563.8...
2:[0]2022-01...
3:[0]sss1 |[1]2 |[2]3
4:[0]4 |[1]5 |[2]6
5:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void removeCache(String cacheKey) {
cache.remove(cacheKey);
}

@InjectValue("@cfg:nop.sys.seq.snowflake-worker-id:0")
@InjectValue("@cfg:nop.sys.seq.snowflake-worker-id|0")
public void setSnowflakeWorkerId(long snowflakeWorkerId) {
this.workerId = snowflakeWorkerId;
}
Expand All @@ -120,7 +120,7 @@ public void afterPropertiesSet() {
String hostId = CFG_HOST_ID.get();
if (StringHelper.isEmpty(hostId))
hostId = NetHelper.findLocalIp();
workerId = HashHelper.murmur3_64_string().hash64(hostId);
workerId = HashHelper.murmur3_32(hostId) % 1024;
}
this.snowflakeGenerator = new SnowflakeSequenceGeneator(workerId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
import io.nop.sys.dao.entity.NopSysCodeRule;
import io.nop.sys.dao.entity.NopSysNoticeTemplate;
import io.nop.xlang.api.XLang;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import jakarta.inject.Inject;
import java.sql.Timestamp;
import java.time.LocalDate;

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

Expand Down Expand Up @@ -51,6 +52,7 @@ public void testCodeRule() {
entity.setName("abc");
scope.setLocalValue("entity", entity);
String code = codeRuleGenerator.generate("test", scope);
assertEquals("D2023abc001", code);
int year = LocalDate.now().getYear();
assertEquals("D" + year + "abc001", code);
}
}

0 comments on commit f78bc30

Please sign in to comment.