|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.maven.shared.release.transform.domtrip; |
| 20 | + |
| 21 | +import eu.maveniverse.domtrip.Document; |
| 22 | +import eu.maveniverse.domtrip.Editor; |
| 23 | +import org.junit.jupiter.api.Test; |
| 24 | + |
| 25 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 26 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 27 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 28 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 29 | + |
| 30 | +class DomTripBuildTest { |
| 31 | + |
| 32 | + private DomTripBuild createBuild(String xml) { |
| 33 | + Document document = Document.of(xml); |
| 34 | + Editor editor = new Editor(document); |
| 35 | + return new DomTripBuild(document.root(), editor); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + void testGetExtensionsEmpty() { |
| 40 | + assertNotNull(createBuild("<build></build>").getExtensions()); |
| 41 | + assertEquals(0, createBuild("<build></build>").getExtensions().size()); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + void testGetExtensionsEmptyContainer() { |
| 46 | + assertEquals( |
| 47 | + 0, createBuild("<build><extensions/></build>").getExtensions().size()); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + void testGetExtensionsOne() { |
| 52 | + assertEquals( |
| 53 | + 1, |
| 54 | + createBuild("<build><extensions><extension/></extensions></build>") |
| 55 | + .getExtensions() |
| 56 | + .size()); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + void testGetPluginManagementMissing() { |
| 61 | + assertNull(createBuild("<build></build>").getPluginManagement()); |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + void testGetPluginManagementPresent() { |
| 66 | + assertNotNull(createBuild("<build><pluginManagement/></build>").getPluginManagement()); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + void testGetPluginsEmpty() { |
| 71 | + assertNotNull(createBuild("<build></build>").getPlugins()); |
| 72 | + assertEquals(0, createBuild("<build></build>").getPlugins().size()); |
| 73 | + } |
| 74 | + |
| 75 | + @Test |
| 76 | + void testGetPluginsEmptyContainer() { |
| 77 | + assertEquals(0, createBuild("<build><plugins/></build>").getPlugins().size()); |
| 78 | + } |
| 79 | + |
| 80 | + @Test |
| 81 | + void testGetPluginsOne() { |
| 82 | + assertEquals( |
| 83 | + 1, |
| 84 | + createBuild("<build><plugins><plugin/></plugins></build>") |
| 85 | + .getPlugins() |
| 86 | + .size()); |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + void testFlushPluginMap() { |
| 91 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 92 | + .flushPluginMap()); |
| 93 | + } |
| 94 | + |
| 95 | + @Test |
| 96 | + void testAddExtension() { |
| 97 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 98 | + .addExtension(null)); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + void testGetOutputDirectory() { |
| 103 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 104 | + .getOutputDirectory()); |
| 105 | + } |
| 106 | + |
| 107 | + @Test |
| 108 | + void testGetScriptSourceDirectory() { |
| 109 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 110 | + .getScriptSourceDirectory()); |
| 111 | + } |
| 112 | + |
| 113 | + @Test |
| 114 | + void testGetSourceDirectory() { |
| 115 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 116 | + .getSourceDirectory()); |
| 117 | + } |
| 118 | + |
| 119 | + @Test |
| 120 | + void testGetTestOutputDirectory() { |
| 121 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 122 | + .getTestOutputDirectory()); |
| 123 | + } |
| 124 | + |
| 125 | + @Test |
| 126 | + void testGetTestSourceDirectory() { |
| 127 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 128 | + .getTestSourceDirectory()); |
| 129 | + } |
| 130 | + |
| 131 | + @Test |
| 132 | + void testRemoveExtension() { |
| 133 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 134 | + .removeExtension(null)); |
| 135 | + } |
| 136 | + |
| 137 | + @Test |
| 138 | + void testSetExtensions() { |
| 139 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 140 | + .setExtensions(null)); |
| 141 | + } |
| 142 | + |
| 143 | + @Test |
| 144 | + void testSetOutputDirectory() { |
| 145 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 146 | + .setOutputDirectory(null)); |
| 147 | + } |
| 148 | + |
| 149 | + @Test |
| 150 | + void testSetScriptSourceDirectory() { |
| 151 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 152 | + .setScriptSourceDirectory(null)); |
| 153 | + } |
| 154 | + |
| 155 | + @Test |
| 156 | + void testSetSourceDirectory() { |
| 157 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 158 | + .setSourceDirectory(null)); |
| 159 | + } |
| 160 | + |
| 161 | + @Test |
| 162 | + void testSetTestOutputDirectory() { |
| 163 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 164 | + .setTestOutputDirectory(null)); |
| 165 | + } |
| 166 | + |
| 167 | + @Test |
| 168 | + void testSetTestSourceDirectory() { |
| 169 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 170 | + .setTestSourceDirectory(null)); |
| 171 | + } |
| 172 | + |
| 173 | + @Test |
| 174 | + void testAddFilter() { |
| 175 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 176 | + .addFilter(null)); |
| 177 | + } |
| 178 | + |
| 179 | + @Test |
| 180 | + void testAddResource() { |
| 181 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 182 | + .addResource(null)); |
| 183 | + } |
| 184 | + |
| 185 | + @Test |
| 186 | + void testAddTestResource() { |
| 187 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 188 | + .addTestResource(null)); |
| 189 | + } |
| 190 | + |
| 191 | + @Test |
| 192 | + void testGetDefaultGoal() { |
| 193 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 194 | + .getDefaultGoal()); |
| 195 | + } |
| 196 | + |
| 197 | + @Test |
| 198 | + void testGetDirectory() { |
| 199 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 200 | + .getDirectory()); |
| 201 | + } |
| 202 | + |
| 203 | + @Test |
| 204 | + void testGetFilters() { |
| 205 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 206 | + .getFilters()); |
| 207 | + } |
| 208 | + |
| 209 | + @Test |
| 210 | + void testGetFinalName() { |
| 211 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 212 | + .getFinalName()); |
| 213 | + } |
| 214 | + |
| 215 | + @Test |
| 216 | + void testGetResources() { |
| 217 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 218 | + .getResources()); |
| 219 | + } |
| 220 | + |
| 221 | + @Test |
| 222 | + void testGetTestResources() { |
| 223 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 224 | + .getTestResources()); |
| 225 | + } |
| 226 | + |
| 227 | + @Test |
| 228 | + void testRemoveFilter() { |
| 229 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 230 | + .removeFilter(null)); |
| 231 | + } |
| 232 | + |
| 233 | + @Test |
| 234 | + void testRemoveResource() { |
| 235 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 236 | + .removeResource(null)); |
| 237 | + } |
| 238 | + |
| 239 | + @Test |
| 240 | + void testRemoveTestResource() { |
| 241 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 242 | + .removeTestResource(null)); |
| 243 | + } |
| 244 | + |
| 245 | + @Test |
| 246 | + void testSetDefaultGoal() { |
| 247 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 248 | + .setDefaultGoal(null)); |
| 249 | + } |
| 250 | + |
| 251 | + @Test |
| 252 | + void testSetDirectory() { |
| 253 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 254 | + .setDirectory(null)); |
| 255 | + } |
| 256 | + |
| 257 | + @Test |
| 258 | + void testSetFilters() { |
| 259 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 260 | + .setFilters(null)); |
| 261 | + } |
| 262 | + |
| 263 | + @Test |
| 264 | + void testSetFinalName() { |
| 265 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 266 | + .setFinalName(null)); |
| 267 | + } |
| 268 | + |
| 269 | + @Test |
| 270 | + void testSetResources() { |
| 271 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 272 | + .setResources(null)); |
| 273 | + } |
| 274 | + |
| 275 | + @Test |
| 276 | + void testSetTestResources() { |
| 277 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 278 | + .setTestResources(null)); |
| 279 | + } |
| 280 | + |
| 281 | + @Test |
| 282 | + void testSetPluginManagement() { |
| 283 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 284 | + .setPluginManagement(null)); |
| 285 | + } |
| 286 | + |
| 287 | + @Test |
| 288 | + void testAddPlugin() { |
| 289 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 290 | + .addPlugin(null)); |
| 291 | + } |
| 292 | + |
| 293 | + @Test |
| 294 | + void testRemovePlugin() { |
| 295 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 296 | + .removePlugin(null)); |
| 297 | + } |
| 298 | + |
| 299 | + @Test |
| 300 | + void testSetPlugins() { |
| 301 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 302 | + .setPlugins(null)); |
| 303 | + } |
| 304 | + |
| 305 | + @Test |
| 306 | + void testGetPluginsAsMap() { |
| 307 | + assertThrows(UnsupportedOperationException.class, () -> createBuild("<build/>") |
| 308 | + .getPluginsAsMap()); |
| 309 | + } |
| 310 | +} |
0 commit comments