-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first definition of create class if not exists method
- Loading branch information
Showing
9 changed files
with
186 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
...ava/com/orientechnologies/orient/core/metadata/schema/CreateClassMultipleClusterTest.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
core/src/test/java/com/orientechnologies/orient/core/metadata/schema/CreateClassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.orientechnologies.orient.core.metadata.schema; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.orientechnologies.BaseMemoryDatabase; | ||
import org.junit.Test; | ||
|
||
public class CreateClassTest extends BaseMemoryDatabase { | ||
|
||
@Test | ||
public void testCreateClassSQL() { | ||
db.command("drop class V").close(); | ||
db.command("create class V clusters 16").close(); | ||
db.command("create class X extends V clusters 32").close(); | ||
|
||
final OClass clazzV = db.getMetadata().getSchema().getClass("V"); | ||
assertEquals(16, clazzV.getClusterIds().length); | ||
|
||
final OClass clazzX = db.getMetadata().getSchema().getClass("X"); | ||
assertEquals(32, clazzX.getClusterIds().length); | ||
} | ||
|
||
@Test | ||
public void testCreateClassSQLSpecifiedClusters() { | ||
int s = db.addCluster("second"); | ||
int t = db.addCluster("third"); | ||
db.command("drop class V").close(); | ||
db.command("create class V cluster " + s + "," + t).close(); | ||
|
||
final OClass clazzV = db.getMetadata().getSchema().getClass("V"); | ||
assertEquals(2, clazzV.getClusterIds().length); | ||
|
||
assertEquals(s, clazzV.getClusterIds()[0]); | ||
assertEquals(t, clazzV.getClusterIds()[1]); | ||
} | ||
|
||
@Test | ||
public void testCreateClassIfNotExists() { | ||
OSchema schema = db.getMetadata().getSchema(); | ||
schema.createClass("TestCreateClass"); | ||
boolean result = schema.createClassIfNotExists("TestCreateClassNotExists"); | ||
assertTrue(result); | ||
assertNotNull(schema.getClass("TestCreateClassNotExists")); | ||
|
||
result = schema.createClassIfNotExists("TestCreateClass"); | ||
assertFalse(result); | ||
} | ||
|
||
@Test | ||
public void testCreateClassIfNotExistsSuperclass() { | ||
OSchema schema = db.getMetadata().getSchema(); | ||
schema.createClass("TestCreateClass"); | ||
boolean result = | ||
schema.createClassIfNotExists("TestCreateClassNotExists", schema.getClass("V")); | ||
assertTrue(result); | ||
assertNotNull(schema.getClass("TestCreateClassNotExists")); | ||
assertEquals(1, schema.getClass("TestCreateClassNotExists").getSuperClasses().size()); | ||
|
||
result = schema.createClassIfNotExists("TestCreateClass"); | ||
assertFalse(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters