1
- package org .bimserver .tests .lowlevel ;
2
-
3
- /******************************************************************************
4
- * Copyright (C) 2009-2019 BIMserver.org
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU Affero General Public License as
8
- * published by the Free Software Foundation, either version 3 of the
9
- * License, or (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU Affero General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Affero General Public License
17
- * along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
18
- *****************************************************************************/
19
-
1
+ package org .bimserver .tests .lowlevel ;
2
+
3
+ /******************************************************************************
4
+ * Copyright (C) 2009-2019 BIMserver.org
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as
8
+ * published by the Free Software Foundation, either version 3 of the
9
+ * License, or (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
18
+ *****************************************************************************/
19
+
20
20
import static org .junit .Assert .fail ;
21
21
22
22
import org .bimserver .interfaces .objects .SProject ;
23
23
import org .bimserver .plugins .services .BimServerClientInterface ;
24
+ import org .bimserver .shared .ChannelConnectionException ;
24
25
import org .bimserver .shared .UsernamePasswordAuthenticationInfo ;
25
- import org .bimserver .shared .exceptions .ErrorCode ;
26
+ import org .bimserver .shared .exceptions .ServiceException ;
26
27
import org .bimserver .shared .exceptions .UserException ;
27
28
import org .bimserver .shared .interfaces .LowLevelInterface ;
28
29
import org .bimserver .test .TestWithEmbeddedServer ;
31
32
public class TestAddReferenceWithOppositeExisting extends TestWithEmbeddedServer {
32
33
33
34
@ Test
34
- public void test () {
35
+ public void test () throws ServiceException , ChannelConnectionException {
36
+ // Create a new BimServerClient with authentication
37
+ BimServerClientInterface bimServerClient = getFactory ().create (new UsernamePasswordAuthenticationInfo ("admin@bimserver.org" , "admin" ));
38
+
39
+ LowLevelInterface lowLevelInterface = bimServerClient .getLowLevelInterface ();
40
+
41
+ // Create a new project
42
+ SProject newProject = bimServerClient .getServiceInterface ().addProject ("test" + Math .random (), "ifc2x3tc1" );
43
+
44
+ // Start a transaction
45
+ Long tid = lowLevelInterface .startTransaction (newProject .getOid ());
46
+
47
+ Long ifcRelContainedInSpatialStructureOid = lowLevelInterface .createObject (tid , "IfcRelContainedInSpatialStructure" , true );
48
+ Long ifcBuildingOid1 = lowLevelInterface .createObject (tid , "IfcBuilding" , true );
49
+ Long ifcBuildingOid2 = lowLevelInterface .createObject (tid , "IfcBuilding" , true );
50
+ lowLevelInterface .addReference (tid , ifcBuildingOid1 , "ContainsElements" , ifcRelContainedInSpatialStructureOid );
51
+
52
+ lowLevelInterface .commitTransaction (tid , "Initial" , false );
53
+
54
+ tid = lowLevelInterface .startTransaction (newProject .getOid ());
55
+ lowLevelInterface .addReference (tid , ifcBuildingOid2 , "ContainsElements" , ifcRelContainedInSpatialStructureOid );
35
56
try {
36
- // Create a new BimServerClient with authentication
37
- BimServerClientInterface bimServerClient = getFactory ().create (new UsernamePasswordAuthenticationInfo ("admin@bimserver.org" , "admin" ));
38
-
39
- LowLevelInterface lowLevelInterface = bimServerClient .getLowLevelInterface ();
40
-
41
- // Create a new project
42
- SProject newProject = bimServerClient .getServiceInterface ().addProject ("test" + Math .random (), "ifc2x3tc1" );
43
-
44
- // Start a transaction
45
- Long tid = lowLevelInterface .startTransaction (newProject .getOid ());
46
-
47
- Long ifcRelContainedInSpatialStructureOid = lowLevelInterface .createObject (tid , "IfcRelContainedInSpatialStructure" , true );
48
- Long ifcBuildingOid1 = lowLevelInterface .createObject (tid , "IfcBuilding" , true );
49
- Long ifcBuildingOid2 = lowLevelInterface .createObject (tid , "IfcBuilding" , true );
50
- lowLevelInterface .addReference (tid , ifcBuildingOid1 , "ContainsElements" , ifcRelContainedInSpatialStructureOid );
51
-
52
- lowLevelInterface .commitTransaction (tid , "Initial" , false );
53
-
54
- tid = lowLevelInterface .startTransaction (newProject .getOid ());
55
- lowLevelInterface .addReference (tid , ifcBuildingOid2 , "ContainsElements" , ifcRelContainedInSpatialStructureOid );
56
- try {
57
- lowLevelInterface .commitTransaction (tid , "2" , false );
58
- } catch (UserException e ) {
57
+ lowLevelInterface .commitTransaction (tid , "2" , false );
58
+ } catch (UserException e ) {
59
59
// if (e.getErrorCode() != ErrorCode.SET_REFERENCE_FAILED_OPPOSITE_ALREADY_SET) {
60
- fail ("Didn't get the right errormessage" );
60
+ fail ("Didn't get the right errormessage" );
61
61
// }
62
- } finally {
63
- fail ("Expected error code" );
64
- }
65
- } catch (Exception e ) {
66
- e .printStackTrace ();
67
- fail (e .getMessage ());
62
+ } finally {
63
+ fail ("Expected error code" );
68
64
}
69
65
}
70
66
}
0 commit comments