Permalink
Browse files

Merge pull request #625 from canoo/AddControllerIntegrationTestsForQu…

…alifire

AddControllerIntegrationTestForQualifier
  • Loading branch information...
hendrikebbers committed Oct 12, 2017
2 parents 76a3dd5 + 5037ee0 commit 2b8c042ac270e4e528e315ed48dd8f8c32749051
@@ -0,0 +1,52 @@
/*
* Copyright 2015-2017 Canoo Engineering AG.
*
* 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 com.canoo.dolphin.integration.qualifier;
import com.canoo.platform.remoting.DolphinBean;
import com.canoo.platform.remoting.Property;
@DolphinBean
public class QualifierTestBean {
private Property<QualifierTestSubBean> qualifierTestSubBeanOneValue;
private Property<QualifierTestSubBean> qualifierTestSubBeanTwoValue;
public QualifierTestSubBean getQualifierTestSubBeanOneValue() {
return qualifierTestSubBeanOneValue.get();
}
public Property<QualifierTestSubBean> qualifierTestSubBeanOneValueProperty() {
return qualifierTestSubBeanOneValue;
}
public void setQualifierTestSubBeanOneValue(QualifierTestSubBean qualifierTestSubBeanValue) {
this.qualifierTestSubBeanOneValue.set(qualifierTestSubBeanValue);
}
public QualifierTestSubBean getQualifierTestSubBeanTwoValue() {
return qualifierTestSubBeanTwoValue.get();
}
public Property<QualifierTestSubBean> qualifierTestSubBeanTwoValueProperty() {
return qualifierTestSubBeanTwoValue;
}
public void setQualifierTestSubBeanTwoValue(QualifierTestSubBean qualifierTestSubBeanTwoValue) {
this.qualifierTestSubBeanTwoValue.set(qualifierTestSubBeanTwoValue);
}
}
@@ -0,0 +1,28 @@
/*
* Copyright 2015-2017 Canoo Engineering AG.
*
* 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 com.canoo.dolphin.integration.qualifier;
public interface QualifierTestConstants {
String QUALIFIER_CONTROLLER_NAME = "QualifierController";
String DUMMY_ACTION = "dummyAction";
String BIND_ACTION = "bindAction";
String UNBIND_ACTION = "unbindAction";
}
@@ -0,0 +1,67 @@
/*
* Copyright 2015-2017 Canoo Engineering AG.
*
* 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 com.canoo.dolphin.integration.qualifier;
import com.canoo.platform.remoting.DolphinBean;
import com.canoo.platform.remoting.Property;
@DolphinBean
public class QualifierTestSubBean {
private Property<Boolean> booleanValue;
private Property<Integer> integerValue;
private Property<String> stringValue;
public Boolean getBooleanValue() {
return booleanValue.get();
}
public Property<Boolean> booleanValueProperty() {
return booleanValue;
}
public void setBooleanValue(Boolean booleanValue) {
this.booleanValue.set(booleanValue);
}
public Integer getIntegerValue() {
return integerValue.get();
}
public Property<Integer> integerValueProperty() {
return integerValue;
}
public void setIntegerValue(Integer integerValue) {
this.integerValue.set(integerValue);
}
public String getStringValue() {
return stringValue.get();
}
public Property<String> stringValueProperty() {
return stringValue;
}
public void setStringValue(String stringValue) {
this.stringValue.set(stringValue);
}
}
@@ -0,0 +1,99 @@
/*
* Copyright 2015-2017 Canoo Engineering AG.
*
* 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 com.canoo.dolphin.integration.server.qualifier;
import com.canoo.dolphin.integration.qualifier.QualifierTestBean;
import com.canoo.dolphin.integration.qualifier.QualifierTestSubBean;
import com.canoo.platform.remoting.BeanManager;
import com.canoo.platform.remoting.Binding;
import com.canoo.platform.remoting.server.DolphinAction;
import com.canoo.platform.remoting.server.DolphinController;
import com.canoo.platform.remoting.server.DolphinModel;
import com.canoo.platform.remoting.server.binding.PropertyBinder;
import com.canoo.platform.remoting.server.binding.Qualifier;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import static com.canoo.dolphin.integration.qualifier.QualifierTestConstants.BIND_ACTION;
import static com.canoo.dolphin.integration.qualifier.QualifierTestConstants.DUMMY_ACTION;
import static com.canoo.dolphin.integration.qualifier.QualifierTestConstants.QUALIFIER_CONTROLLER_NAME;
import static com.canoo.dolphin.integration.qualifier.QualifierTestConstants.UNBIND_ACTION;
@DolphinController(QUALIFIER_CONTROLLER_NAME)
public class QualifierTestController {
private final static Qualifier<String> STRING_QUALIFIER = Qualifier.create();
private final static Qualifier<Boolean> BOOLEAN_QUALIFIER = Qualifier.create();
private final static Qualifier<Integer> INTEGER_QUALIFIER = Qualifier.create();
@DolphinModel
private QualifierTestBean model;
@Inject
private BeanManager beanManager;
@Inject
private PropertyBinder binder;
final private List<Binding> bindings = new ArrayList<>();
@PostConstruct
public void init() {
QualifierTestSubBean qualifierTestSubBeanOne = beanManager.create(QualifierTestSubBean.class);
model.setQualifierTestSubBeanOneValue(qualifierTestSubBeanOne);
QualifierTestSubBean qualifierTestSubBeanTwo = beanManager.create(QualifierTestSubBean.class);
model.setQualifierTestSubBeanTwoValue(qualifierTestSubBeanTwo);
bind();
}
private void bind() {
bindings.add(binder.bind(model.getQualifierTestSubBeanOneValue().booleanValueProperty(), BOOLEAN_QUALIFIER));
bindings.add(binder.bind(model.getQualifierTestSubBeanOneValue().stringValueProperty(), STRING_QUALIFIER));
bindings.add(binder.bind(model.getQualifierTestSubBeanOneValue().integerValueProperty(), INTEGER_QUALIFIER));
bindings.add(binder.bind(model.getQualifierTestSubBeanTwoValue().booleanValueProperty(), BOOLEAN_QUALIFIER));
bindings.add(binder.bind(model.getQualifierTestSubBeanTwoValue().stringValueProperty(), STRING_QUALIFIER));
bindings.add(binder.bind(model.getQualifierTestSubBeanTwoValue().integerValueProperty(), INTEGER_QUALIFIER));
}
private void unbind() {
for(Binding binding : bindings) {
binding.unbind();
}
bindings.clear();
}
@DolphinAction(DUMMY_ACTION)
public void dummyAction() {}
@DolphinAction(BIND_ACTION)
public void bindAction() {
bind();
}
@DolphinAction(UNBIND_ACTION)
public void unbindAction() {
unbind();
}
}
Oops, something went wrong.

0 comments on commit 2b8c042

Please sign in to comment.