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+
2020import static org .junit .Assert .fail ;
2121
2222import org .bimserver .interfaces .objects .SProject ;
2323import org .bimserver .plugins .services .BimServerClientInterface ;
24+ import org .bimserver .shared .ChannelConnectionException ;
2425import org .bimserver .shared .UsernamePasswordAuthenticationInfo ;
25- import org .bimserver .shared .exceptions .ErrorCode ;
26+ import org .bimserver .shared .exceptions .ServiceException ;
2627import org .bimserver .shared .exceptions .UserException ;
2728import org .bimserver .shared .interfaces .LowLevelInterface ;
2829import org .bimserver .test .TestWithEmbeddedServer ;
3132public class TestAddReferenceWithOppositeExisting extends TestWithEmbeddedServer {
3233
3334 @ 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 (
"[email protected] " ,
"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 );
3556 try {
36- // Create a new BimServerClient with authentication
37- BimServerClientInterface bimServerClient =
getFactory ().
create (
new UsernamePasswordAuthenticationInfo (
"[email protected] " ,
"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 ) {
5959// 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" );
6161// }
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" );
6864 }
6965 }
7066}
0 commit comments