Changeset 9e4bc5e766622e597afd6c642de28b7d86e7b04d
- Timestamp:
- 02/24/08 12:21:24 (8 months ago)
- git-parent:
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
test/java/net/driftingsouls/ds2/server/werften/WerftObjectTest.java
rccb5b31 r9e4bc5e 35 35 public class WerftObjectTest extends DriftingSoulsDBTestCase { 36 36 private WerftObject werft; 37 private WerftObject werftKomplex; 38 private WerftObject werftKomplexPart; 37 39 38 40 /** … … 45 47 46 48 this.werft = (WerftObject)db.get(WerftObject.class, 1); 49 assertThat(this.werft, not(nullValue())); 50 51 this.werftKomplex = (WerftObject)db.get(WerftObject.class, 2); 52 assertThat(this.werftKomplex, not(nullValue())); 53 54 this.werftKomplexPart = (WerftObject)db.get(WerftObject.class, 3); 55 assertThat(this.werftKomplexPart, not(nullValue())); 47 56 } 48 57 … … 56 65 @Test 57 66 public void destroyWerft() { 58 assertThat(this.werft, not(nullValue()));67 org.hibernate.Session db = context.getDB(); 59 68 60 69 this.werft.destroy(); 61 62 org.hibernate.Session db = context.getDB();63 70 64 71 WerftObject werftAfterDelete = (WerftObject)db.get(WerftObject.class, 1); … … 68 75 assertThat(entry, nullValue()); 69 76 } 77 78 /** 79 * Testet die Destroy-Operation bei Werftkomplexen 80 */ 81 @Test 82 public void destroyWerftKomplex() { 83 org.hibernate.Session db = context.getDB(); 84 85 this.werftKomplex.destroy(); 86 87 WerftObject werftAfterDelete = (WerftObject)db.get(WerftObject.class, 2); 88 assertThat(werftAfterDelete, nullValue()); 89 90 WerftQueueEntry entry = (WerftQueueEntry)db.get(WerftQueueEntry.class, 2); 91 assertThat(entry, nullValue()); 92 93 entry = (WerftQueueEntry)db.get(WerftQueueEntry.class, 3); 94 assertThat(entry, nullValue()); 95 } 96 97 /** 98 * Testet die Destroy-Operation bei Werftkomplexen ausgehend von einem Teil 99 */ 100 @Test 101 public void destroyWerftKomplexPart() { 102 org.hibernate.Session db = context.getDB(); 103 104 this.werftKomplexPart.destroy(); 105 106 WerftObject werftAfterDelete = (WerftObject)db.get(WerftObject.class, 3); 107 assertThat(werftAfterDelete, nullValue()); 108 109 WerftQueueEntry entry = (WerftQueueEntry)db.get(WerftQueueEntry.class, 2); 110 assertThat(entry, not(nullValue())); 111 112 entry = (WerftQueueEntry)db.get(WerftQueueEntry.class, 3); 113 assertThat(entry, not(nullValue())); 114 } 115 116 /** 117 * Testet {@link WerftObject#getBuildQueue()} 118 */ 119 @Test 120 public void getBuildQuery() { 121 WerftQueueEntry[] entries = this.werft.getBuildQueue(); 122 assertThat(entries, not(nullValue())); 123 assertThat(entries.length, is(1)); 124 assertThat(entries[0].getBuildShipType().getTypeId(), is(1)); 125 126 entries = this.werftKomplex.getBuildQueue(); 127 assertThat(entries, not(nullValue())); 128 assertThat(entries.length, is(2)); 129 assertThat(entries[0].getBuildShipType().getTypeId(), is(1)); 130 assertThat(entries[1].getBuildShipType().getTypeId(), is(1)); 131 132 entries = this.werftKomplexPart.getBuildQueue(); 133 assertThat(entries, not(nullValue())); 134 assertThat(entries.length, is(0)); 135 } 136 137 /** 138 * Testet {@link WerftObject#getKomplex()} 139 */ 140 @Test 141 public void getKomplex() { 142 assertThat(this.werft.getKomplex(), nullValue()); 143 assertThat(this.werftKomplex.getKomplex(), nullValue()); 144 assertThat(this.werftKomplexPart.getKomplex(), is(this.werftKomplex)); 145 } 146 147 /** 148 * Testet {@link WerftObject#getBuildQueueEntry(int)} 149 */ 150 @Test 151 public void getBuildQueueEntry() { 152 WerftQueueEntry entry = this.werft.getBuildQueueEntry(0); 153 assertThat(entry, not(nullValue())); 154 assertThat(entry.getBuildShipType().getTypeId(), is(1)); 155 156 entry = this.werft.getBuildQueueEntry(1); 157 assertThat(entry, nullValue()); 158 159 entry = this.werftKomplex.getBuildQueueEntry(1); 160 assertThat(entry, not(nullValue())); 161 assertThat(entry.getBuildShipType().getTypeId(), is(1)); 162 163 entry = this.werftKomplexPart.getBuildQueueEntry(1); 164 assertThat(entry, nullValue()); 165 } 70 166 } test/java/net/driftingsouls/ds2/server/werften/WerftObjectTest.xml
rccb5b31 r9e4bc5e 6 6 <ship_types id="1" nickname="GTS Zephyrus" picture="" ru="2" rd="5" ra="0" rm="110" eps="150" 7 7 cost="3" hull="30000" cargo="1500" heat="2" crew="30" weapons="" maxheat="" 8 size="14" descrip="" deutfactor="3" class="3" flags="" modules="" />8 size="14" descrip="" deutfactor="3" class="3" flags="" modules="" werft="8" /> 9 9 10 10 <bases id="1" name="Testasti" owner="1" x="5" y="1" system="1" bewohner="1" arbeiter="0" e="1000" … … 12 12 terrain="" bebauung="" active="" autogtuacts="" /> 13 13 14 <!-- Basiswerft --> 15 14 16 <werften id="1" type="0" flagschiff="0" col="1" /> 15 17 <werft_queues id="1" werft="1" position="0" building="1" item="-1" remaining="1" flagschiff="0" 16 costsPerTick="" energyPerTick="0" slots="1" scheduled="1" /> 18 costsPerTick="" energyPerTick="0" slots="1" scheduled="1" /> 19 20 <!-- Werftkomplex --> 21 22 <ships id="1" owner="1" name="Werft" type="1" cargo="" 23 x="1" y="1" system="1" crew="30" e="150" hull="30000" heat="" history="" /> 24 <ships id="2" owner="1" name="Werft" type="1" cargo="" 25 x="1" y="1" system="1" crew="30" e="150" hull="30000" heat="" history="" /> 26 <ships id="3" owner="1" name="Werft" type="1" cargo="" 27 x="1" y="1" system="1" crew="30" e="150" hull="30000" heat="" history="" /> 28 29 <werften id="2" type="0" flagschiff="0" komplex="1" /> 30 <werft_queues id="2" werft="2" position="0" building="1" item="-1" remaining="1" flagschiff="0" 31 costsPerTick="" energyPerTick="0" slots="1" scheduled="1" /> 32 <werft_queues id="3" werft="2" position="1" building="1" item="-1" remaining="1" flagschiff="0" 33 costsPerTick="" energyPerTick="0" slots="1" scheduled="1" /> 34 35 <werften id="3" type="0" flagschiff="0" shipid="1" linkedWerft="2" /> 36 <werften id="4" type="0" flagschiff="0" shipid="2" linkedWerft="2" /> 37 <werften id="5" type="0" flagschiff="0" shipid="2" linkedWerft="2" /> 17 38 </dataset>
