private void assertRestrictions(Class<? extends ArtifactRestrictions> type, ImmutableList<ArtifactRestrictions> expected, ChangeInput actual) { assertEquals(getRestrictionsByType(type, expected).getIncludes(), getRestrictionsByType(type, actual.getRestrictions()).getIncludes()); assertEquals(getRestrictionsByType(type, expected).getExcludes(), getRestrictionsByType(type, actual.getRestrictions()).getExcludes()); }
@Test public void testExcludeEnvs() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("excludeEnvs", "dev1,dev3")) ); assertEquals(1, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class)); assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getExcludes()); assertTrue(restrictions.getFirst().getIncludes().isEmpty()); }
@Test public void testIncludeEnvs() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("includeEnvs", "dev1,dev3")) ); assertEquals(1, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class)); assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getIncludes()); assertTrue(restrictions.getFirst().getExcludes().isEmpty()); }
@Test public void testIncludeEnvsExcludePlatforms() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with( "includeEnvs", "dev1,dev3", "excludePlatforms", "HSQL,HIVE")) ); assertEquals(2, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class)); assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getIncludes()); assertTrue(restrictions.getFirst().getExcludes().isEmpty()); assertThat(restrictions.getLast(), instanceOf(ArtifactPlatformRestrictions.class)); assertTrue(restrictions.getLast().getIncludes().isEmpty()); assertEquals(UnifiedSet.newSetWith("HSQL", "HIVE"), restrictions.getLast().getExcludes()); } }
@Test public void testIncludePlatforms() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("includePlatforms", "DB2,SYBASE_ASE")) ); assertEquals(1, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactPlatformRestrictions.class)); assertEquals(UnifiedSet.newSetWith("DB2", "SYBASE_ASE"), restrictions.getFirst().getIncludes()); assertTrue(restrictions.getFirst().getExcludes().isEmpty()); }
@Test public void testExcludePlatforms() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("excludePlatforms", "HSQL,HIVE")) ); assertEquals(1, restrictions.size()); assertEquals(UnifiedSet.newSetWith("HSQL", "HIVE"), restrictions.getFirst().getExcludes()); assertTrue(restrictions.getFirst().getIncludes().isEmpty()); }