Package jeeves.server.context

Examples of jeeves.server.context.ServiceContext


        assertEquals(Boolean.FALSE.toString(), result.getText());
    }

    @Test
    public void testAddToExistingGroup() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final String value = "x/y/z";
        final SchematronCriteriaType criteriaType = SchematronCriteriaType.XPATH;
        String uiCriteriaType = "uiType";
        String uiValue = "uiValue";
        Element params = createParams(
                read(SchematronCriteriaService.PARAM_GROUP_NAME, _group1_Name1_SchematronId1.getId().getName()),
                read(SchematronCriteriaService.PARAM_SCHEMATRON_ID, _group1_Name1_SchematronId1.getId().getSchematronId()),
                read(SchematronCriteriaService.PARAM_TYPE, criteriaType),
                read(SchematronCriteriaService.PARAM_VALUE, value),
                read(SchematronCriteriaService.PARAM_UI_TYPE, uiCriteriaType),
                read(SchematronCriteriaService.PARAM_UI_VALUE, uiValue)
        );

        Element result = createService(ADD).exec(params, context);
        assertSuccessfulAdd(result);
        String id = result.getChildText("id");

        params = createParams(
                read(Params.ID, id)
        );

        result = createService(EXISTS).exec(params, context);
        assertEquals(Boolean.TRUE.toString(), result.getText());

        final SchematronCriteria saved = context.getBean(SchematronCriteriaRepository.class).findOne(Integer.parseInt(id));

        assertEquals(value, saved.getValue());
        assertEquals(criteriaType, saved.getType());
        assertEquals(uiValue, saved.getUiValue());
        assertEquals(uiCriteriaType, saved.getUiType());
View Full Code Here


        assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
    }

    @Test
    public void testAddToNewGroup() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final String uitype = "uitype";
        final String uivalue = "uivalue";
        final String value = "x/y/z";
        final SchematronCriteriaType criteriaType = SchematronCriteriaType.XPATH;
        String newName = "newGroupName" + _inc.incrementAndGet();
        final int schematronId = _group1_Name1_SchematronId1.getId().getSchematronId();

        Element params = createParams(
                read(SchematronCriteriaService.PARAM_GROUP_NAME, newName),
                read(SchematronCriteriaService.PARAM_SCHEMATRON_ID, schematronId),
                read(SchematronCriteriaService.PARAM_TYPE, criteriaType),
                read(SchematronCriteriaService.PARAM_VALUE, value),
                read(SchematronCriteriaService.PARAM_UI_TYPE, uitype),
                read(SchematronCriteriaService.PARAM_UI_VALUE, uivalue)
        );

        assertFalse(context.getBean(SchematronCriteriaGroupRepository.class).exists(new SchematronCriteriaGroupId(newName,
                schematronId)));

        Element result = createService(ADD).exec(params, context);
        assertSuccessfulAdd(result);
        String id = result.getChildText("id");

        final SchematronCriteriaGroup found = context.getBean(SchematronCriteriaGroupRepository.class).findOne(new
                SchematronCriteriaGroupId(newName, schematronId));
        assertTrue(found != null);
        assertEquals(SchematronRequirement.REQUIRED, found.getRequirement());

        params = createParams(
                read(Params.ID, id)
        );

        result = createService(EXISTS).exec(params, context);
        assertEquals(Boolean.TRUE.toString(), result.getText());

        final SchematronCriteria saved = context.getBean(SchematronCriteriaRepository.class).findOne(Integer.parseInt(id));

        assertEquals(value, saved.getValue());
        assertEquals(criteriaType, saved.getType());
        assertEquals(uivalue, saved.getUiValue());
        assertEquals(uitype, saved.getUiType());
View Full Code Here

        assertEquals(schematronId, saved.getGroup().getId().getSchematronId());
    }

    @Test
    public void testEdit() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final String value = "x/y/z";
        final SchematronCriteriaType criteriaType = SchematronCriteriaType.XPATH;
        String uiType = "editedUiType";
        String uiValue = "editedUiValue";
        final int criteriaId = _group1_Name1_SchematronId1.getCriteria().get(0).getId();

        Element params = createParams(
                read(Params.ID, criteriaId),
                read(SchematronCriteriaService.PARAM_TYPE, criteriaType),
                read(SchematronCriteriaService.PARAM_VALUE, value),
                read(SchematronCriteriaService.PARAM_UI_TYPE, uiType),
                read(SchematronCriteriaService.PARAM_UI_VALUE, uiValue)
        );

        assertEquals("ok", createService(EDIT).exec(params, context).getName());

        final SchematronCriteria saved = context.getBean(SchematronCriteriaRepository.class).findOne(criteriaId);

        assertEquals(value, saved.getValue());
        assertEquals(criteriaType, saved.getType());
        assertEquals(uiValue, saved.getUiValue());
        assertEquals(uiType, saved.getUiType());
View Full Code Here

        assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
    }

    @Test
    public void testEditSetValueOnly() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final SchematronCriteria criteria = _group1_Name1_SchematronId1.getCriteria().get(0);
        final int criteriaId = criteria.getId();
        final String newValue = "newValue"+_inc.incrementAndGet();
        Element params = createParams(
                read(Params.ID, criteriaId),
                read(SchematronCriteriaService.PARAM_VALUE, newValue)
        );

        assertEquals("ok", createService(EDIT).exec(params, context).getName());

        final SchematronCriteria saved = context.getBean(SchematronCriteriaRepository.class).findOne(criteriaId);

        assertEquals(newValue, saved.getValue());
        assertEquals(criteria.getType(), saved.getType());
        assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
    }
View Full Code Here

        assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
    }

    @Test
    public void testEditSetTypeOnly() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final SchematronCriteria criteria = _group1_Name1_SchematronId1.getCriteria().get(0);
        final int criteriaId = criteria.getId();
        SchematronCriteriaType newType = SchematronCriteriaType.GROUP;
        if (criteria.getType() == SchematronCriteriaType.GROUP) {
            newType = SchematronCriteriaType.ALWAYS_ACCEPT;
        }
        Element params = createParams(
                read(Params.ID, criteriaId),
                read(SchematronCriteriaService.PARAM_TYPE, newType.name())
        );

        assertEquals("ok", createService(EDIT).exec(params, context).getName());

        final SchematronCriteria saved = context.getBean(SchematronCriteriaRepository.class).findOne(criteriaId);

        assertEquals(criteria.getValue(), saved.getValue());
        assertEquals(newType, saved.getType());

        assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
View Full Code Here

        assertEquals(_group1_Name1_SchematronId1.getId(), saved.getGroup().getId());
    }

    @Test
    public void testExecDelete() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final int id = _group1_Name1_SchematronId1.getCriteria().get(0).getId();

        Element deleteParams = createParams(
View Full Code Here

        assertGroupOnlyId(result);
    }

    @Test (expected = BadParameterEx.class)
    public void testExecDeleteBadId() throws Exception {
        ServiceContext context = createServiceContext();
        loginAsAdmin(context);

        final int id = _group1_Name1_SchematronId1.getCriteria().get(0).getId();

        Element deleteParams = createParams(
View Full Code Here

    public void testRun() throws Exception {
        final long numSearches = _searchRequestRepository.count();
        TransactionlessTesting.get().run(new TestTask() {
            @Override
            public void run() throws Exception {
                final ServiceContext context = createServiceContext();
                final SearchLoggerTask task = context.getBean(SearchLoggerTask.class);
                Query query = new TermQuery(new Term("any", "search"));
                task.configure(context, false, "any", query, 3, Sort.RELEVANCE, null, "value");
                task.run();
            }
        });
View Full Code Here

    private AtomicInteger _inc = new AtomicInteger();

    @Test
    public void testAddRemove() throws Exception {
        final ServiceContext serviceContext = createServiceContext();
        loginAsAdmin(serviceContext);

        Element cswHarvesterParams = createHarvesterParams("csw");
        CswHarvesterIntegrationTest.addCswSpecificParams(cswHarvesterParams);

        final String harvesterId = _harvestManager.addHarvesterReturnId(cswHarvesterParams, serviceContext.getUserSession().getUserId());

        final Element harvesterParamsAfterAdd = _harvestManager.get(harvesterId, serviceContext, "date");

        assertNotNull(harvesterParamsAfterAdd);
        assertEquals(harvesterId, harvesterParamsAfterAdd.getAttributeValue("id"));
View Full Code Here

    @Autowired
    protected HarvestManagerImpl _harvestManager;

    @Before
    public void configureHarvesterBeans() throws Exception {
        final ServiceContext serviceContext = createServiceContext();
        loginAsAdmin(serviceContext);

        _harvestManager.init(serviceContext, false);
    }
View Full Code Here

TOP

Related Classes of jeeves.server.context.ServiceContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.