Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 7489e06

Browse files
committed
POLYGENE-121 : Validated that reporting is correct and the issue can be closed.
1 parent 71bad29 commit 7489e06

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

libraries/constraints/src/test/java/org/apache/polygene/library/constraints/HostPortConstraintTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
package org.apache.polygene.library.constraints;
2121

2222
import org.apache.polygene.api.common.Optional;
23+
import org.apache.polygene.api.composite.TransientBuilder;
2324
import org.apache.polygene.api.constraint.ConstraintViolationException;
25+
import org.apache.polygene.api.mixin.Mixins;
26+
import org.apache.polygene.api.mixin.NoopMixin;
2427
import org.apache.polygene.api.property.Property;
2528
import org.apache.polygene.bootstrap.AssemblyException;
2629
import org.apache.polygene.bootstrap.ModuleAssembly;
@@ -83,6 +86,27 @@ public void givenInvalidHostNameWhenSettingPropertyExpectConstrainViolation()
8386
} );
8487
}
8588

89+
@Test
90+
public void givenInvalidHostNameWhenConstructingExpectConstrainViolation()
91+
throws Exception
92+
{
93+
TransientBuilder<SomeValue> builder = transientBuilderFactory.newTransientBuilder( SomeValue.class );
94+
assertThrows( ConstraintViolationException.class, () -> {
95+
builder.prototype().hostPort().set( "1:2:3_i:1234" );
96+
builder.newInstance();
97+
} );
98+
}
99+
100+
@Test
101+
public void givenInvalidHostNameWhenCallingServiceExpectConstrainViolation()
102+
throws Exception
103+
{
104+
SomeService someService = serviceFinder.findService( SomeService.class ).get();
105+
assertThrows( ConstraintViolationException.class, () -> {
106+
someService.doSomething( "1:2:3_i:1234" );
107+
} );
108+
}
109+
86110
@Test
87111
public void givenInvalidPortNumberWhenSettingPropertyExpectConstrainViolation()
88112
throws Exception
@@ -114,6 +138,7 @@ public void assemble( ModuleAssembly module )
114138
throws AssemblyException
115139
{
116140
module.transients( SomeValue.class );
141+
module.services( SomeService.class );
117142
}
118143

119144
public interface SomeValue
@@ -122,4 +147,10 @@ public interface SomeValue
122147
@Optional
123148
Property<String> hostPort();
124149
}
150+
151+
@Mixins( NoopMixin.class )
152+
public interface SomeService
153+
{
154+
void doSomething(@HostPort String hostPort);
155+
}
125156
}

0 commit comments

Comments
 (0)