PolygonWithoutSurfaceCheckTest.java 2.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package de.hft.stuttgart.citydoctor2.checks.semantics;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.ErrorId;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.error.PolygonWithoutSurfaceError;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;

public class PolygonWithoutSurfaceCheckTest {

	@Test
	public void testPolygonWithoutSurface() {
		Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
		Polygon poly = new ConcretePolygon();
		geom.addPolygon(poly);
		PolygonWithoutSurfaceCheck check = new PolygonWithoutSurfaceCheck();
		poly.accept(check);
		CheckResult checkResult = poly.getCheckResult(check);
		assertNotNull(checkResult);
		assertEquals(ResultStatus.ERROR, checkResult.getResultStatus());
		assertEquals(CheckId.C_SE_POLYGON_WITHOUT_SURFACE, checkResult.getCheckIdentifier());
		CheckError error = checkResult.getError();
		assertNotNull(error);
		assertEquals(ErrorId.SE_POLYGON_WITHOUT_SURFACE, error.getErrorId()); 
		assertTrue(error instanceof PolygonWithoutSurfaceError);
		PolygonWithoutSurfaceError errorCast = (PolygonWithoutSurfaceError) error;
		assertSame(poly, errorCast.getPolygon());
	}
	
	@Test
	public void testPolygonWithSurface() {
		Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD2);
		Polygon poly = new ConcretePolygon();
		BoundarySurface bs = new BoundarySurface(null);
		bs.addGeometry(geom);
		geom.addPolygon(poly);
		PolygonWithoutSurfaceCheck check = new PolygonWithoutSurfaceCheck();
		poly.accept(check);
		CheckResult checkResult = poly.getCheckResult(check);
		assertNotNull(checkResult);
		assertEquals(ResultStatus.OK, checkResult.getResultStatus());
		assertEquals(CheckId.C_SE_POLYGON_WITHOUT_SURFACE, checkResult.getCheckIdentifier());
		CheckError error = checkResult.getError();
		assertNull(error);
	}
	
	@Test
	public void testPolygonWithWrongLod() {
		Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD1);
		Polygon poly = new ConcretePolygon();
		BoundarySurface bs = new BoundarySurface(null);
		bs.addGeometry(geom);
		geom.addPolygon(poly);
		PolygonWithoutSurfaceCheck check = new PolygonWithoutSurfaceCheck();
		poly.accept(check);
		CheckResult checkResult = poly.getCheckResult(check);
		assertNull(checkResult);
	}

}