Inferred type error when calling Robolectric.buildActivity() - robolectric

I am using robolectric 2.2.
I am trying out following example code from the Robolectric project:
#RunWith(RobolectricTestRunner.class)
public class RoboTest {
#Test
public void test() {
MainActivity activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().get();
}
}
Unfortunately I get following error:
Inferred type 'frontend.android.MainActivity' for type parameter 'T' is not within its bound; should extend 'android.app.Activity'
Why do I get this error when my MainActivity extends from android.app.Activity?

Related

Error when extending FungibleToken: supportedSchemas() in QueryableState clashes with supportedSchemas() in FungibleState

I'm using the Java template (token-template branch), tokens SDK version is 1.1-SNAPSHOT.
I'm extending FungibleToken class to add one extra attribute (PublicKey owningAccount) and I'm getting this error inside Intellij (as red underlines):
supportedSchemas() in QueryableState clashes with supportedSchemas() in FungibleState, attempting to use incompatible type
When I add the below function; the compile error is gone (Intellij no longer shows red underlines), but I get a different error on ./gradlew deployNodes:
#NotNull
#Override
public List<FungibleTokenSchemaV1> supportedSchemas() {
return super.supportedSchemas();
}
Build error:
> Task :contracts:compileJava FAILED
MyToken.java:33: error: supportedSchemas() in MyToken cannot implement supportedSchemas() in QueryableState
public List<FungibleTokenSchemaV1> supportedSchemas() {
^
return type List<FungibleTokenSchemaV1> is not compatible with Iterable<MappedSchema>
1 error
Even though List is Iterable and FungibleTokenSchemaV1 is MappedSchmea.
Full code of class:
public class MyToken extends FungibleToken {
private final PublicKey owningAccount;
public Shoken(Amount<IssuedTokenType> amount,
AbstractParty holder,
SecureHash tokenTypeJarHash,
PublicKey owningAccount) {
super(amount, holder, tokenTypeJarHash);
this.owningAccount = owningAccount;
}
public PublicKey getOwningAccount() {
return owningAccount;
}
#NotNull
#Override
public List<FungibleTokenSchemaV1> supportedSchemas() {
return super.supportedSchemas();
}
}
I would suggest you to use evolvableTokentype to issue tokens with evolvable attributes. The FungibleToken and NonFungibleToken objects are only the instruments that carries the issuance of the tokens. The underlying template of the token is what stores the information.
Feel free to look at our TokenSDK workshop at https://www.youtube.com/watch?v=IAViczRAEyU.

Unable to load Java class that consist robotframework keywords while it is trying to utilize method of another class via Object of that class

I have Class B which has Robotframework keyword and also calls method from Class A through
object. I am getting 'NoClassDefFoundError' for Class A when trying to use keyword of Class B. But, If I remove usage of class A in class B, I am able to use keywords of Class B. Below are my code:
Scenario 1: Error triggered
public class A{
public void method1(){
System.out.println("This is method1")
}
}
public class B{
public void myRobotKeyword(){
A obj = new A();
obj.method1();
System.out.println("This is my kwyword");
}
}
Scenario 2: Successful retrieval of keyword in my test
public class B{
public void myRobotKeyword(){
System.out.println("This is my keyword");
}
}

swift 3 override init does not override / cannot find overloads

I can't seem to extend a class from cocoapod ra1028/Former in my application with the right initializers from the parent class. Why is this?
See below situation divided into the code from the pod and my application code (ExtendedFormLabelHeaderView class)
// ra1028/Former cocaopod class signatures
public protocol FormableView: class {}
public protocol LabelFormableView: FormableView {}
open class FormHeaderFooterView: UITableViewHeaderFooterView {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override public init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
}
}
open class FormLabelHeaderView: FormHeaderFooterView, LabelFormableView {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override public init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
}
}
// my app code
open class ExtendedFormLabelHeaderView: FormLabelHeaderView {
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override public init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
}
}
Running above code in the playground works.
But running it as setup in my workspace (coming from Swift 2.2, converted to Swift 3) it will first complain about ExtendedFormLabelHeaderView's override init(reuseIdentifier: String?) initializer not being public (most likely because it cannot find the initializer it needs to override?) and then I end up with these error messages:
Initializer does not override a designated initializer from its superclass.
Argument labels '(reuseIdentifier:)' do not match any available overloads
Some other things to note:
It worked back in 2.2
I updated Former to the latest Swift 3.0 version
Removing the override keyword from the offending initializer in my ExtendedFormLabelHeaderView class will give a different error for the first line: Initializer 'init(reuseIdentifier:)' with Objective-C selector initWithReuseIdentifier:' conflicts with implicit initializer 'init(reuseIdentifier:)' from superclass

scaffolding Error There is no implicit reference conversion from Configuration to System.Data.Entity.Migrations.DbMigrationsConfiguration

I utuliz EF 6.0.2 Code First, VS 2013, MVC 5 and have dbContext and configuration class derived from dbMigrationConfiguratino class like this:
public class Db : DbContext
{
public Db()
{
Database.SetInitializer(new MigrateDatabaseToLatestVersion<Db,Migrations.Configuration -- my Derived dbMigrationConfig Classs In Migrations folder-->());
}
public DbSet<ItemCat> ItemCats { get; set; }
public DbSet<Item> Items { get; set; }
}
and
public sealed class Configuration : DbMigrationsConfiguration<Db>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
}
protected override void Seed(Db context)
{
}
}
From here Implicit refrience conversion for From any
class-type S to any class-type T, provided S is derived from T.
is valid. like my configuration and DbMigrationConfiguration
but when want add View for a Controller get error:
Microsoft Visual Studio
Error
There was an error running the selected code generator:
'There was an error in compilation of the type 'DAL.Db'.
CS0311: The type 'DAL.Migrations.Configuration' cannot be used as
type parameter 'TMigrationsConfiguration' in the generic type or
method
'System.Data.Entity.MigrateDatabaseToLatestVersion'.
There is no implicit reference conversion from
'DAL.Migrations.Configuration' to
'System.Data.Entity.Migrations.DbMigrationsConfiguration'.'
OK
Edit:
find this:
CS3011 Error
Edit: I figure out my Db Class To :
public class Db :MigrateDatabaseToLatestVersion<DbContext,Migrations.Configuration>
{
//Database.SetInitializer(new MigrateDatabaseToLatestVersion<Db,Migrations.Configuration>());
}
and get same bolded above error compile time

Cannot resolve the controller

Previously I was not using an interface for my generic repository. When I extracted the interface from my generic repository, I added two constructors: a parameterless and a parameterized constructors I am getting the following error:
{"Resolution of the dependency failed, type = \"NascoBenefitBuilder.Controllers.ODSController\", name = \"(none)\".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, ControllerLib.Models.Generic.IGenericRepository, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving NascoBenefitBuilder.Controllers.ODSController,(none)
Resolving parameter \"repo\" of constructor NascoBenefitBuilder.Controllers.ODSController(ControllerLib.Models.Generic.IGenericRepository repo)
Resolving ControllerLib.Models.Generic.IGenericRepository,(none)"}
My Controller at the beginning:
public class ODSController : ControllerBase
{
IGenericRepository _generic = new GenericRepository();
}
After extracting the interface and use it in controller:
public class ODSController : ControllerBase
{
IGenericRepository _generic;
public ODSController() : this(new GenericRepository())
{
}
public ODSController(IGenericRepository repo)
{
_generic = repo;
}
}
When I use parameterized constructor it is throwing error mentioned above.
Can anyone help me to overcome this problem?
You no longer need the default constructor:
public class ODSController : ControllerBase
{
private readonly IGenericRepository _repository;
public ODSController(IGenericRepository repository)
{
_repository = repository;
}
}
And then make sure you've properly configured your Unity container:
IUnityContainer container = new UnityContainer()
.RegisterType<IGenericRepository, GenericRepository>();
And that you are using the Unity controller factory in Application_Start:
ControllerBuilder.Current.SetControllerFactory(typeof(UnityControllerFactory));

Resources