Skip to content

Commit

Permalink
moditect#7 Expanding test
Browse files Browse the repository at this point in the history
gunnarmorling committed Jan 2, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c6a552f commit e65f5e5
Showing 10 changed files with 217 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -19,7 +19,13 @@

import org.junit.Test;
import org.moditect.deptective.plugintest.PluginTestBase;
import org.moditect.deptective.plugintest.basic.bar.Bar;
import org.moditect.deptective.plugintest.basic.barctorcall.BarCtorCall;
import org.moditect.deptective.plugintest.basic.barfield.BarField;
import org.moditect.deptective.plugintest.basic.barlocalvar.BarLocalVar;
import org.moditect.deptective.plugintest.basic.barloopvar.BarLoopVar;
import org.moditect.deptective.plugintest.basic.barparameter.BarParameter;
import org.moditect.deptective.plugintest.basic.barretval.BarRetVal;
import org.moditect.deptective.plugintest.basic.bartypearg.BarTypeArg;
import org.moditect.deptective.plugintest.basic.foo.Foo;

import com.google.testing.compile.Compilation;
@@ -35,14 +41,42 @@ public void shouldDetectDisallowedPackageDependence() {
getConfigFileOption()
)
.compile(
forTestClass(Bar.class),
forTestClass(BarCtorCall.class),
forTestClass(BarField.class),
forTestClass(BarLocalVar.class),
forTestClass(BarLoopVar.class),
forTestClass(BarParameter.class),
forTestClass(BarRetVal.class),
forTestClass(BarTypeArg.class),
forTestClass(Foo.class)
);

assertThat(compilation).failed();

// TODO https://github.com/moditect/deptective/issues/7
// assertThat(compilation).hadErrorContaining(
// "package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barctorcall"
// );
assertThat(compilation).hadErrorContaining(
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barfield"
);
assertThat(compilation).hadErrorContaining(
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barlocalvar"
);
assertThat(compilation).hadErrorContaining(
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barloopvar"
);
assertThat(compilation).hadErrorContaining(
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.bar"
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barparameter"
);

// TODO https://github.com/moditect/deptective/issues/7
// assertThat(compilation).hadErrorContaining(
// "package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barretval"
// );
// assertThat(compilation).hadErrorContaining(
// "package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.bartypearg"
// );
}

@Test
@@ -54,13 +88,19 @@ public void shouldUseWarnReportingPolicy() {
"-Adeptective.reportingpolicy=WARN"
)
.compile(
forTestClass(Bar.class),
forTestClass(BarCtorCall.class),
forTestClass(BarField.class),
forTestClass(BarLocalVar.class),
forTestClass(BarLoopVar.class),
forTestClass(BarParameter.class),
forTestClass(BarRetVal.class),
forTestClass(BarTypeArg.class),
forTestClass(Foo.class)
);

assertThat(compilation).succeeded();
assertThat(compilation).hadWarningContaining(
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.bar"
"package org.moditect.deptective.plugintest.basic.foo does not read org.moditect.deptective.plugintest.basic.barfield"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright 2019 The ModiTect authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.barctorcall;

public class BarCtorCall {

}
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.bar;
package org.moditect.deptective.plugintest.basic.barfield;

public class Bar {
public class BarField {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright 2019 The ModiTect authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.barlocalvar;

public class BarLocalVar {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright 2019 The ModiTect authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.barloopvar;

public class BarLoopVar {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright 2019 The ModiTect authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.barparameter;

public class BarParameter {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright 2019 The ModiTect authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.barretval;

public class BarRetVal {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright 2019 The ModiTect authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.moditect.deptective.plugintest.basic.bartypearg;

public class BarTypeArg {

}
Original file line number Diff line number Diff line change
@@ -15,10 +15,37 @@
*/
package org.moditect.deptective.plugintest.basic.foo;

import org.moditect.deptective.plugintest.basic.bar.Bar;
import java.util.ArrayList;
import java.util.List;

import org.moditect.deptective.plugintest.basic.barctorcall.BarCtorCall;
import org.moditect.deptective.plugintest.basic.barfield.BarField;
import org.moditect.deptective.plugintest.basic.barlocalvar.BarLocalVar;
import org.moditect.deptective.plugintest.basic.barloopvar.BarLoopVar;
import org.moditect.deptective.plugintest.basic.barparameter.BarParameter;
import org.moditect.deptective.plugintest.basic.barretval.BarRetVal;
import org.moditect.deptective.plugintest.basic.bartypearg.BarTypeArg;

public class Foo {

private String s;
private final Bar bar = new Bar();
private final BarField bar = new BarField();

public Foo(BarParameter bar) {
}

public BarRetVal doSomething(BarParameter bar) {
BarLocalVar varLocalVar = new BarLocalVar();

List<BarTypeArg> bars = new ArrayList<>();

for (BarLoopVar oneBar : new ArrayList<BarLoopVar>()) {
}

new BarCtorCall();

return null;
}


}
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
{
"packages" : [
{
"name" : "org.moditect.deptective.plugintest.basic.bar"
"name" : "org.moditect.deptective.plugintest.basic.barctorcall"
},
{
"name" : "org.moditect.deptective.plugintest.basic.barfield"
},
{
"name" : "org.moditect.deptective.plugintest.basic.barlocalvar"
},
{
"name" : "org.moditect.deptective.plugintest.basic.barloopvar"
},
{
"name" : "org.moditect.deptective.plugintest.basic.barparameter"
},
{
"name" : "org.moditect.deptective.plugintest.basic.barretval"
},
{
"name" : "org.moditect.deptective.plugintest.basic.bartypearg"
},
{
"name" : "org.moditect.deptective.plugintest.basic.foo",
"reads" : [
"java.lang"
"java.lang",
"java.util"
]
}
]

0 comments on commit e65f5e5

Please sign in to comment.