Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.codeforces.inmemo</groupId>
<artifactId>inmemo</artifactId>
<version>2.0-SNAPSHOT</version>
<version>2.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>inmemo</name>
<distributionManagement>
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/codeforces/inmemo/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ public static String getTableClassSpec(Class<?> clazz) {

StringBuilder result = new StringBuilder();
for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
result.append(propertyDescriptor.getName())
.append(':')
.append(propertyDescriptor.getPropertyType().getName())
.append(',');
Class<?> propertyType = propertyDescriptor.getPropertyType();
if (propertyType != null) {
result.append(propertyDescriptor.getName())
.append(':')
.append(propertyType.getName())
.append(',');
}
}

return result.toString();
Expand Down
18 changes: 10 additions & 8 deletions src/test/java/com/codeforces/inmemo/InmemoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ public boolean testItem(User user) {
}
};
Inmemo.createTable(User.class, "ID", null, new Indices.Builder<User>() {{
add(Index.create("ID", Long.class, User::getId));
}}.build(), adminFilter, true);
add(Index.create("ID", Long.class, User::getId));
}}.build(), adminFilter, true);
int size = Inmemo.size(User.class);
org.junit.Assert.assertTrue(size >= USER_COUNT * 0.45 && size <= USER_COUNT * 0.55);

for (User user : userDao.findAll()) {
Inmemo.insertOrUpdate(user);
}
org.junit.Assert.assertEquals(size, Inmemo.size(User.class));
org.junit.Assert.assertEquals(size, Inmemo.size(User.class));

List<User> admins = new ArrayList<>();
List<User> nonAdmins = new ArrayList<>();
Expand Down Expand Up @@ -485,9 +485,9 @@ public void testEmergency() throws InterruptedException {
));
add(Index.createUnique("handle", String.class, User::getHandle));
add(Index.createUnique("idAndHandle", String.class, user -> user.getId() + "," + user.getHandle(), indexValue -> {
String[] tokens = indexValue.split(",");
return new Object[]{"ID", Long.valueOf(tokens[0]), "HANDLE", tokens[1]};
}
String[] tokens = indexValue.split(",");
return new Object[]{"ID", Long.valueOf(tokens[0]), "HANDLE", tokens[1]};
}
));
add(Index.create("FIRST_HANDLE_LETTER", String.class, tableItem -> tableItem.getHandle().substring(0, 1)));
}}.build(), true);
Expand Down Expand Up @@ -690,7 +690,7 @@ public void testJournal() throws IOException {
}

Map<Long, User> users = new HashMap<>();
for (long id = 1; id <= USER_COUNT ; id++) {
for (long id = 1; id <= USER_COUNT; id++) {
User inmemoUser = Inmemo.findOnly(true, User.class, new IndexConstraint<>("ID", id));
User dbUser = userDao.find(id);
Assert.assertEquals(dbUser, inmemoUser);
Expand All @@ -705,12 +705,14 @@ public void testJournal() throws IOException {
}}.build(), true);
}

for (long id = 1; id <= USER_COUNT ; id++) {
for (long id = 1; id <= USER_COUNT; id++) {
User inmemoUser = Inmemo.findOnly(true, User.class, new IndexConstraint<>("ID", id));
User dbUser = userDao.find(id);
Assert.assertEquals(dbUser, inmemoUser);
Assert.assertEquals(users.get(id), inmemoUser);
}
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
Assert.assertTrue(journalFile.isFile());
Inmemo.deleteJournal(User.class);
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/codeforces/inmemo/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public void setTShirtSize(TShirtSize tShirtSize) {
this.tShirtSize = tShirtSize;
}

public int getSomething(int arg) {
return arg + 2;
}

public int getSomethingWithTwoArgs(int arg1, int arg2) {
return arg1 + arg2;
}

public void setSomething() {}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down