小编jen*_*gar的帖子

测试是否调用了另一种方法

所以我确定那里有类似的东西,但我一直在寻找一个小时,并没有找到我正在寻找的东西.说我有一个看起来像这样的课:

public class MyClass
{
    public void myMethod(boolean shouldCallOtherMethod)
    {
        if(shouldCallOtherMethod)
        {
            otherMethod();
        }
    }

    public void otherMethod()
    {
        System.out.println("Called");
    }
}
Run Code Online (Sandbox Code Playgroud)

我如何制作这样的作品?

@Test
public void shouldCallMethod()
{
    MyClass myClass = new MyClass();
    myClass.myMethod(true)

    // verify myClass.otherMethod method was called
}
Run Code Online (Sandbox Code Playgroud)

java junit mockito powermock

10
推荐指数
2
解决办法
4484
查看次数

android键盘移动标签

所以我有一个我刚刚构建的Ionic/Phonegap应用程序,ionic start myApp tabs然后我在其中一个视图上添加了一个输入.当我使用Android模拟器或设备聚焦输入时,键盘会出现,但选项卡也会出现.每当Android上的键盘处于活动状态时,我是否必须明确隐藏选项卡?我认为这将是一个常见的问题,但我没有看到任何投诉.我只是有一个糟糕的项目或什么?

android cordova ionic-framework

10
推荐指数
1
解决办法
1584
查看次数

Chrome开发者工具无法看到javascript

所以我有一个非常奇怪的事情,我的javascript没有显示在我的源窗口中.如果我debugger在我的js中设置一个然后重新加载页面,它将会中断,我可以看到javascript.奇怪的是,不是标签被标记,MyJavascriptFile.js而是读取[VM](62)或其他数字.我尝试重新安装chrome,它没有解决我的问题.它曾经不像这样,任何想法是怎么回事?通过添加调试器语句来获取我的javascript真的很烦人.

javascript google-chrome google-chrome-devtools

6
推荐指数
2
解决办法
4711
查看次数

Spring Data JPA存储库:派生查询中的IN子句不起作用

我有一个看起来像这样的存储库:

public interface UserRepository extends JpaRepository<User, Long>
{
    User findByEmailIgnoreCase(String email);

    @Query("select u from User u where u.id in (:ids)")
    Set<User> getByIdInSet(@Param("ids") Set<Long> ids);
}
Run Code Online (Sandbox Code Playgroud)

当我打电话时,getByIdInSet我收到以下错误:

Caused by: java.lang.IllegalArgumentException: You have attempted to set a value of type class org.eclipse.persistence.indirection.IndirectSet for parameter ids with expected type of class java.lang.Long from query string select u from User u where u.id in (:ids).
    at org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:933)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:593)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
Run Code Online (Sandbox Code Playgroud)

显然我不知道是什么意思,因为我尝试更改各种数据类型,仍然得到相同的错误.我传递的id组只包含一个id.请指出我正确的方向.

java jpa spring-data spring-data-jpa

6
推荐指数
2
解决办法
2万
查看次数

将数据传递给transcluded元素

我想创建一个指令来组织按日期分组的显示数据.我还希望能够指定一个显示各行的指令.在一个完美的世界里,它会看起来像这样(但很漂亮)

Friday, Oct 28
    [some directive html]
    [some directive html]
    [some directive html]
Saturday, Oct 29
    [some directive html]
Sunday, Oct 30
    [some directive html]
    [some directive html]
...
Run Code Online (Sandbox Code Playgroud)

这显然不起作用,所以如果你有更好的方法,请告诉我,但我希望能够按照这些方针做一些事情:

app.directive('dateOrganized', [function(){
    return {
        template:
            '<div>' +
                '<div ng-repeat="organizedDate in organizedDate">' +
                    '<div>{{organizedDate.date | date}}</div>' +
                    '<div ng-repeat="item in organizedDate.items">' +
                        '{{rowDirectiveHtml}}' +
                    '</div>' +
                '</div>' +
            '</div>',
        scope: {
            organizedDates: '=',
            rowDirectiveHtml: '='
        }
        ...
    };
}])

app.directive('itemRow', [function(){
    return {
        template: '<div>{{item.data}}</div>',
        scope: {
            item: '='
        }
    }; …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

6
推荐指数
1
解决办法
2893
查看次数

Linq查询使用列表或ID数组

我无法弄清楚如何使用cq中的linq查询数据库以获取与列表或数组相对应的所有对象并将它们放入列表中.例如:

我有一张物品.我想构建一个方法来检索其id在pass数组或列表中的所有项.我用google搜索它但它总是假设我只想查询列表或数组而不是查询使用列表或数组.

提前致谢.

c# linq entity-framework

5
推荐指数
1
解决办法
1万
查看次数

queryDSL 实体的列表包含所有

所以我真的一直在努力解决这个问题,但似乎没有关于如何做到这一点的好的文档。我有一个带有实体RepairMan列表的Skill实体。我需要一个可以返回一个List<RepairMan>包含所有技能 ID 的技能列表的查询。下面是实体的样子:

@Entity
@Table(name = "REPAIRMAN")
public class RepairMan implements Serializable
{
    private static final long serialVersionUID = 8151638047721448259L;

    @SequenceGenerator(name="REPAIRMAN_SEQ", sequenceName="REPAIRMAN_SEQ", allocationSize=1, initialValue=100)
    @Id @GeneratedValue(generator="REPAIRMAN_SEQ")
    private Long id;

    @OneToMany
    @JoinTable(name="REPAIRMAN_SKILLS", joinColumns=@JoinColumn(name="REPAIRMAN_ID"), inverseJoinColumns=@JoinColumn(name="SKILL_ID"))
    private List<Skill> skills;

    ....
}



@Entity
@Table(name = "SKILL")
public abstract class Skill implements Serializable
{
    private static final long serialVersionUID = -5272849377636005084L;

    @SequenceGenerator(name="SKILL_SEQ_GEN", sequenceName="SKILL_SEQ", allocationSize=1, initialValue=100)
    @Id 
    @GeneratedValue(generator="SKILL_SEQ_GEN", strategy=GenerationType.SEQUENCE)
    private Long id;

    @Column(name="NAME")
    private String name;

    @Column(name="DESCRIPTION")
    private String description; …
Run Code Online (Sandbox Code Playgroud)

java jpa querydsl

5
推荐指数
0
解决办法
1666
查看次数

IntelliJ无法查找测试上下文

我在使用intelliJ运行单元测试时遇到问题.我已经浏览了其他论坛,人们有类似的问题,但到目前为止,我仍然无法让它工作.这是错误:

java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: java.io.FileNotFoundException: class path resource [com/d1/d2/service/ServiceTest-context.xml] cannot be opened because it does not exist
Run Code Online (Sandbox Code Playgroud)

在我的测试中,我有:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "ServiceTest-context.xml")
public class ServiceImplTest ....
Run Code Online (Sandbox Code Playgroud)

我已经明确证实该文件存在于由行引起的位置.我还读了一个检查输出目录的建议,我已经验证它也存在.还有什么比你更突出的吗?我可以使用ant从命令行运行测试,但我希望能够运行单个类而不是模块.

项目:

IntelliJ_project
    src
    test
        com
            d1
                d2
                    otherStuff
                    ...
                    ...
                    service
                        ServiceImplTest.java
                        ServiceTest-context.xml
Run Code Online (Sandbox Code Playgroud)

导出目录:

test-classes (output folder)
    com
        d1
            d2
                service
                    ServiceImplTest.class
Run Code Online (Sandbox Code Playgroud)

所以事实证明我在错误的目录中寻找输出.上下文文件不会使其到达输出位置.我怎么去那里?

java junit intellij-idea

4
推荐指数
2
解决办法
8851
查看次数

类型“ IArguments”不是数组类型

我正在尝试创建自定义记录器。很简单,但是我试图摆脱错误,所以我没有泥泞的输出。我有这样的事情:

@Injectable()
export class Logger {
    log(...args: any[]) {
        console.log(...arguments);
    }
}
Run Code Online (Sandbox Code Playgroud)

但它在控制台中出现以下错误:

Logger.ts(6,9): Error TS2346: Supplied parameters do not match any signature of call target.
Run Code Online (Sandbox Code Playgroud)

Logger.ts(6,24): Error TS2461: Type 'IArguments' is not an array type.
Run Code Online (Sandbox Code Playgroud)

正确的方法是什么?

typescript angular

4
推荐指数
2
解决办法
2943
查看次数

覆盖angular forEach中的属性

我想这是一件容易的事情,但我无法通过谷歌找到我想要的信息.我有popupProperties哪些只是默认的东西.然后我调用返回特定覆盖的服务,具体取决于弹出窗口.如何迭代所有服务的覆盖并将其应用于popupProperties

var popupProperties = getDefaultPopupProperties();
var popupOverrides= popupService.getPopupOverrides(currPopupId);

angular.forEach(popupOverrides, function(popupProperty, propertyName){
    //replace defaults with popupData's properties
});
Run Code Online (Sandbox Code Playgroud)

angularjs

3
推荐指数
1
解决办法
3010
查看次数