PowerMockIgnore all package except one class - powermock

Is there any way to annotate #PowerMockIgnore to ignore the whole package except just one class inside this package?
I was hoping to do something like for example:
#PowerMockIgnore({ "foo.bar.ignore*\DoNotIgnoreClass"})

Use the #PrepareForTest annotation:
e.g.
#PrepareForTest(DoNotIgnoreClass.class)
or for multiple classes:
#PrepareForTest({DoNotIgnoreClass.class, Another.class})

Related

How to check if a class mixin has been applied to a Polymer element?

I would like to check if a mixin has been applied to a custom element, but I don't think I can use 'instanceof', since a mixin is not properly a base class (I tried, of course).
I would need to enforce that an element added to a collection can be only of a kind with a particular class mixin applied...
Any suggestions?
Not sure I understand you question correctly.
I assume you want to check something like MyCustomElement has already apply MyMixin or not?
You can check from the instance
let instance = new MyCustomElement()
console.log(instance instanceof MyMixin)
This will only work when MyMixin is a class not a factory function. If you follow documentation you need to change it.
Another way, you can declare some static function in MyMixin. Then you can call from MyCustomElement to check it.

Problems with Yii2 creation Rules

I have a Yii2 with Yii2 admin, user andAdminLTE installed. My problem is I don't know how to create rules, actually I don't know how to define the Class Name. Where "Classes" should be defined? How can I see which Classes do I have or add Classes?
Thanks a lot,
The class that you'll enter should be the child class of yii\rbac\Rule. So, in order to make a rule you need to provide the namespace of this child class. Suppose, if the name of the child class is TestRule and the namespace of this class is app\test. Then you must write the class name as app\test\TestRule.
And your TestRule class must look like
namespace app\test;
class TestRule extends yii\rbac\Rule{
...
}

Is it possible to access a class outside package from other package?

I have a class like this
package test{
class Test{}
}
class TestInnerClass{}
I can access the TestInnerClass from Test class but I need to access the TestInnerClass(as class, not its instance) from other class as well. And I don't really want to make TestInnerClass an independent class as all it contains are a few variables.
Is there any way to access the class from outside Test class?
[edit]
More specifically, I need the access for the following code to work.
registerClassAlias("TestInnerClass",TestInnerClass);
If you have a class that would not otherwise be accessed except internally by a public class you may define it as internal.
Internal classes are visible to references inside the current package.
In your example, TestInnerClass is only visible to Test.
Otherwise, to access the class or register class alias it must be defined public in its own .as file.
Packages help to order and classify code in hierarchy. Often, I'll keep Value Object or Data Transfer Objects within their own package, such as:
com.jasonsturges.model.vo
This helps to group smaller model classes together.
If you wanted to make a class visible outside of it's containing package your class would be defined as so:
// SampleCode.as file
package samples{
public class SampleCode {}
}
// CodeFormatter.as file
package samples{
class CodeFormatter {}
}
The SampleCode class is visible whilst the CodeFormatter class is not.
Hope I've answered your question

Create setter for a style property

I want to make a setter for the fontSize property of my WrappedLabel class because I need to do some additional stuff when someone changes it.
So when someone uses my class like this:
<comp:WrappedLabel fontSize="10"/>
I want to know.
I tried to override setStyle but looks like it doesn't get called when fontSize is initialized in mxml.
That's actually easier to accomplish then you might think, but it involves metadata. All you need to do is add a Style metadata declaration to your class definition, like so:
[Style(name="fontSize", type="Number", inherit="no")]
public class WrappedLabel {
...
}
If you want more information on the parameters of the metadata, read the docs.

Document class silently fails

I have this weird issue while compiling my .fla file : it won't use the Document class. Here is the document class. (note that the parent class EditorPlugin extends Sprite).
package com.myproject.plugins.editor {
import flash.display.MovieClip;
import com.myproject.editor.EditorPlugin;
import com.myproject.editor.tools.EpisodeEditorTool;
import com.myproject.editor.tools.NewTabTool;
import com.myproject.editor.tools.ToolManager;
public class EpisodeEditorPlugin extends EditorPlugin{
public function EpisodeEditorPlugin(){
trace("creating", this);
AddAuth(ToolManager.EDIT_EPISODE_AUTH, ToolManager.EDIT_EPISODE_AUTH, EpisodeEditorTool, ToolManager.EDIT_EPISODE_LABEL);
}
}
}
The weird part is that in the line below, if I use NewTabTool instead of EpisodeEditorTool, the code works just fine, but with EpisodeEditorTool, the Class is not instanciated. There are no warnings or compiling errors, but i don't get the trace. I loaded the resulting .swf, it is not of type EpisodeEditorPlugin, but rather a simple MovieClip (via getQualifiedClassName() and is EpisodeEditorPlugin).
The EpisodeEditorTool and NewTabTool are quite similar even though of different use, but very huge, here are their declarations :
public class EpisodeEditorTool extends JPanel implements ITool{
and
public class NewTabTool extends JPanel implements ITool{
I should add that both class contain no error (at least according to Flash) and have been compiled in other .flas before. the only problem I can see is that EpisodeEditorTool is even more huge(r?) than other ITools.
Does anyone have any idea of how a document class could fail to be applied? And fail silently at that?
Thanks!
The only thing I can really think of is that you're not specifying the name of the Document class correctly inside the Flash IDE. Inside the Properties panel there's a box where you enter the name of your Document class, which you must presumably have used if the Document class works when you rename the class to NewTabTool. I guess you put NewTabTool into that box, then changed the actual class' name, and forgot to change the reference in the Properties panel. I've forgotten that little bit when changing the name of my Document class before, I hope your solution is as simple as that!
debu